N,X = gets.split.map(&:to_i)
P = Array.new(N + 1, 1)
H = Array.new(N + 1, 1)
(1 .. N).each do |n|
  H[n] = 3 + 2 * H[n - 1]
  P[n] = 1 + 2 * P[n - 1]
end

def answer(n, h)
  if h.zero?
    return 0
  elsif n > 0 && h == 1
    return 0
  elsif h == H[n]
    return P[n]
  end
  
  if h == H[n - 1] + 2
    return P[n - 1] + 1
  elsif h > H[n - 1] + 2
    return P[n - 1] + 1 + answer(n - 1, h - (H[n - 1] + 2))
  else
    return answer(n - 1, h - 1)
  end
end

puts answer(N, X)