def get_burger_num(n)
  return 1 if n == 0
  return 2*get_burger_num(n-1)+3
end

def get(n, x) # nはバーガーのレベル、xは食べる層数. 食べるパティの層数を吐き出す
  burger_num = get_burger_num(n)
  if n == 0
    return 1
  end

  if x <= 1
    return 0
  elsif x <= get_burger_num(n-1)+1
    return get(n-1, x-1)
  elsif x == get_burger_num(n-1)+2
    return get(n-1, x-1) + 1
  elsif x <= 2*get_burger_num(n-1)+3
    return get(n-1, x-1) + 1 + get(n-1, x-2-get_burger_num(n-1))
  else
    return 2*get(n-1, x-1) + 1
  end
end

n, x = gets.chomp.split(' ').map(&:to_i)
puts get(n, x)