n,x = gets.split.map(&:to_i)
patti = [1]
sum = [1]
mid = [1]
n.times do |i|
  patti << patti[-1]*2 +1
  sum << sum[-1] * 2 + 3
  mid << sum[i] + 2
end
lv = n
ans = 0
while lv > 0
  if x >= mid[lv]
    ans += patti[lv-1] + 1
    x -= mid[lv]
  else
    x -= 1
  end
  lv -= 1
end
p ans