a = int(input())
it = int(input())
for i in range(it):
    if a % 2:
        a = a * 3 + 1
    else:
        a /= 2
print(int(a))

492b2bec070f1c86872428d0915375aa2dde8495
<mask token>

<mask token>
for i in range(it):
    if a % 2:
        a = a * 3 + 1
    else:
        a /= 2
print(int(a))

a = int(input())
it = int(input())
for i in range(it):
    if a % 2:
        a = a * 3 + 1
    else:
        a /= 2
print(int(a))
