N,M = map(int, input().split()) ans1 = 1 for i in range(N): if pow(2,i+1)<=M: ans1+=pow(2,i+1) else: break ans = M while N>1 and M>=2: M = -(-M//2) ans += M N-=1 if M>=2: print(ans1) else: print(ans+N-1)