def calc(n, count, k)
  if n == 0
    return count 
  else
    calc(n-1, count * 2 + k, k)
  end
end

def solve(n, k, total_p, total, ans)
  if k == 0
    return ans
  elsif k == (total - 1) / 2
    return ans + (total_p + 1) / 2
  elsif k == total - 1
    return ans + total_p
  end
  if (total - 1) / 2 > k
    solve(n - 1, k - 1, (total_p - 1) / 2, (total - 3) / 2, ans)
  else
    solve(n - 1, k - (total + 1) / 2 , (total_p - 1) / 2, (total - 3) / 2, ans + (total_p + 1) / 2)
  end
end
  
n, k = gets.split.map(&:to_i)
p = calc(n, 1, 1)
t = calc(n, 1, 3)

puts solve(n, k - 1, p, t, 0)
