#yuki1869 n,x=map(int,input().split()) if n<=60 and 2**(n-1)<=x: print(2**n-1) else: res=0 while x!=1: res+=x x=(x+1)//2 n-=1 res+=n print(res)