def size(n)
  (4 << n) - 3
end

def patty(n)
  (2 << n) - 1
end


n, x = gets.split.map(&:to_i)
patties = 0

(n-1).downto(0) do |n|
  if x < 1
    break
  elsif x < size(n) + 1
    x -= 1
  elsif x == size(n) + 1
    x = 0
    patties += patty(n)
  else
    x -= (size(n) + 2)
    patties += patty(n) + 1
  end
end

if x > 0
  patties += 1
end

p patties
