n,m=list (map(int,input ().split())) def f(x,y): def a(x,y): if x==1: return 1 return min(2*a(x-1,y),y,) if x==1: return 1 elif y%2==0: return f(x-1,int(y/2))+a(x-1,int(y/2))*2 else: return f(x-1,int((y+1)/2))+a(x-1,int((1+y)/2))*2-1 peint(f(n,m))