N, xin = gets.split.map(&:to_i)
array = Array.new(50,0)
parray = Array.new(50,0)
array[0] = 1
parray[0] = 1
1.upto(50) do |i|
  array[i] = array[i-1]*2 + 3
  parray[i] = parray[i-1]*2 + 1
end
ans = 0
while xin > 1
51.times do |i|
  if array[i+1] > xin
    ans += parray[i] + 1
    xin = xin - array[i] -2
#    puts "ans #{ans} // x #{xin} // "
    break
  end
end
end
puts ans
