def full(n)
  if n==0
    1
  else
    2*full(n-1)+1
  end
end
def whole(n)
  if n==0
    1
  else
    2*full(n-1)+3
  end
end

def partial(n,x)
  if n==0
    return x
  end
  u=whole(n-1)
  if x<=u+1
    if x<=1
      return 0
    end
    return partial(n-1,x-1)
  end
  return full(n-1)+partial(n-1,[x-u-2,u].min)+1
end

n,x=gets.split.map &:to_i
puts partial(n,x)