input = STDIN.readlines.map{|line|line.strip.split()}
line = input.shift
n = line[0].to_i
x = line[1].to_i

p_counts = [1]
whole_counts = [1]

n.times do |i|
    p_counts.push(2 * p_counts[i] + 1)
    whole_counts.push(2 * whole_counts[i] + 3)
end

l = 1
r = whole_counts[-1]
ans = p_counts.pop

while l <= r do
    center = (l + r) >> 1
    pc = p_counts.pop
    if pc.nil? then
        pc = 0
    end
    if x > center then
        r -= 1
        l = center + 1
    else
        l += 1
        r = center - 1
        ans -= pc
        if  x == center
            break
        end
        ans -= 1
    end
end
puts(ans)