n, x = gets.split.map(&:to_i)

$h = {0 => 'P'}

def burger(l)
    return $h[l] if $h[l]
    $h[l] = 'B' + burger(l - 1) + 'P' + burger(l - 1) + 'B'
end

ans = 0
s = burger(n)
(0...x).each{|i| ans += 1 if s[i] == 'P'}
puts(ans)