local inp = io.read()
local n,x
for i=1,string.len(inp),1 do
  if inp:sub(i,i)==' ' then
    n = tonumber(inp:sub(1,i-1))
    x = tonumber(inp:sub(i+1,string.len(inp)))
  end
end
local le = {}
local p = {}

function f(x,n)
  if x == 0 then
    return 0
  elseif n == 0 then
    return 1
  elseif 2*x<le[n+1] then
    return f(x-1,n-1)
  else
    return p[n]+1+f(x-le[n]-2,n-1)
   end
end

le[1]=1
for i=1,n,1 do
  le[i+1]=le[i]*2+3
end
p[1]=1
for i=1,n,1 do
  p[i+1]=p[i]*2+1
end
print(f(x,n))