#!/usr/bin/env ruby
n, x = STDIN.readline.strip.split(' ').map(&:to_i)

def make_size_map(n)
  size_map = []
  l = 1
  for i in 1..n do
    l = 1 + l + 1 + l + 1
    size_map[i] = l
  end
  size_map
end

# B BPPPB P BPPPB B
# 1 23456 7 89012 3
def count_patty(n, x)
  size_map = make_size_map(n)
  l = size_map[n]
  if n == 0
    1
  elsif x == 1
    0
  elsif x == l
    2 * count_patty(n-1, (l-3)/2) + 1
  elsif x == (l+1)/2
    count_patty(n-1, (l-3)/2) + 1
  elsif x > (l+1)/2
    count_patty(n-1, (l-3)/2) + 1 + count_patty(n-1, x-((l-3)/2+2))
  elsif x < (l+1)/2
    count_patty(n-1, x-1)
  end
end

puts count_patty(n, x)