n, x = gets.chomp.split(" ").map(&:to_i)
n = n+1
hsh = {}
hsh[0] = [1, 1]
n.times do |i|
  if i == 0
    next
  end
  hsh[i] = [hsh[i-1][0] * 2+1, hsh[i-1][1]*2+3]
end
c = 0
idx = 0
n.times do |i|
  i = n - i - 1
  if i == 0
    if x > 0
      c += 1
    end
    break
  end

  if x == (hsh[i][1] -1)/2+1
    c += hsh[i-1][0]+1
    break
  elsif x > (hsh[i][1] -1)/2+1
    c += hsh[i-1][0]+1
    x = x -  ((hsh[i][1] -1)/2+1)
  elsif x < (hsh[i][1] -1)/2+1
     x = x -1
  end
end
puts c