n,x = gets.split.map(&:to_i)
p,b = 2.times.map{Array.new(51,0)}
p[0] = 1
50.times do |i|
    p[i+1] = p[i]*2+1
    b[i+1] = b[i]*2+2
end

ans = 0
while x > 0
    if x >= p[n]+b[n]
        x -= p[n]+b[n]
        ans += p[n]
        break if x == 0
        x -= 1
        ans += 1
    else
        x -= 1
        n -= 1
    end
end
puts ans