#include <iostream>
using namespace std;
int main() {
int c, n;
cin>>c;
cin>>n;
for(int i=1;i<=n;++i) {
if(c%2) {
c=3*c+1;
} else {
c=c/2;
}
}
cout<<c<<endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgYywgbjsKCWNpbj4+YzsKCWNpbj4+bjsKCWZvcihpbnQgaT0xO2k8PW47KytpKSB7CgkJaWYoYyUyKSB7CgkJCWM9MypjKzE7CgkJfSBlbHNlIHsKCQkJYz1jLzI7CgkJfQoJfQoJY291dDw8Yzw8ZW5kbDsKCXJldHVybiAwOwp9