N,M = map(int, input().split()) ans = M while N>1 and M>=2: M = -(-M//2) ans += M N-=1 print(ans+N-1)