#include <iostream>
using namespace std;
class A {
private:
unsigned int counter =0;
public:
void update(){
++counter;
}
void display()
{
cout << counter;
}
};
class B {
private:
A & a;
public:
B(A & na ):a(na) { }
void run()
{
a.update();
}
};
int main() {
A a;
B b1(a);
B b2(a);
b1.run();
b2.run();
a.display();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY2xhc3MgQSB7Cglwcml2YXRlOgoJdW5zaWduZWQgaW50IGNvdW50ZXIgPTA7CglwdWJsaWM6Cgl2b2lkIHVwZGF0ZSgpewoJCSsrY291bnRlcjsKCX0KCXZvaWQgZGlzcGxheSgpCgl7CgkJY291dCA8PCBjb3VudGVyOwoJfQp9OwoKY2xhc3MgQiB7Cglwcml2YXRlOgoJQSAmIGE7CgkKCXB1YmxpYzoKCUIoQSAmIG5hICk6YShuYSkgeyB9CgkKCXZvaWQgcnVuKCkKCXsKCQlhLnVwZGF0ZSgpOwoJfQp9OwoKCmludCBtYWluKCkgewoJQSBhOwoJQiBiMShhKTsKCUIgYjIoYSk7CgkKCWIxLnJ1bigpOwoJYjIucnVuKCk7CglhLmRpc3BsYXkoKTsKCQoJcmV0dXJuIDA7Cn0=