from collections import deque n,k = map(int,input().split()) lis = deque() lis.append(k) cnt = 1 while(k > 1): if(k % 2 == 0): k //= 2 else: k = k // 2 + 1 lis.append(k) cnt += 1 if(n >= cnt): print(sum(lis) + n - cnt) else: i = 0 ans = 0 while(i < n): ans += 2 ** i i += 1 print(ans)