def eat(n,x)
  if n == 0
    return 1
  end
  if x == 1
    return 0
  elsif 1 < x && x <= 1 + $array[n-1]
    return eat(n-1,x-1)
  elsif x == 2 + $array[n-1]
    return $parray[n-1] + 1
  elsif 2 + $array[n-1] < x && x <= 2 + $array[n-1]*2
    return eat(n-1,x-$array[n-1]-2) + $parray[n-1] +1
  elsif x == $array[n]
    return $parray[n]
  end
end
$array = Array.new(51,0)
$parray = Array.new(51,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
n,x = gets.split.map(&:to_i)
puts eat(n,x)
