n, x = gets.split.map(&:to_i)
s = [1]
pp = [1]
n.times do 
    s << s[-1] * 2 + 3
    pp << pp[-1] * 2 + 1
end

def calc(s, pp, k, i)
    if i == 0
        1
    elsif k >= s[i - 1] + 2
        pp[i - 1] + 1 + calc(s, pp, k - s[i - 1] - 2, i - 1)
    elsif k >= s[i - 1] + 1
        pp[i - 1]
    elsif k > 1
        calc(s, pp, k - 1, i - 1)
    else
        0
    end
end

puts calc(s, pp, x, n)
