N, X = gets.split.map(&:to_i)

@p = [1]; (1 .. N).each{|n| @p[n] = 2*@p[n - 1] + 1}
@l = [1]; (1 .. N).each{|n| @l[n] = 2*@l[n - 1] + 3}

def f(n, x)
  return x <= 0 ? 0 : 1 if n == 0
  return f(n - 1, x - 1) if x <= @l[n - 1] + 1
  @p[n - 1] + 1 + f(n - 1, x - @l[n - 1] - 2)
end

puts f(N, X)