def ascan; gets.split.map(&:to_i); end


# B[L-1]P[L-1]B

@memo = {}
@memomax = {}
# return: [total, numP]
def solve(n, x)
    if @memo.size > 1000
        @memo.each{|e| p e}
        exit
    end
    return [0, 0] if x <= 0
    return [1, 1] if n == 0
    return [1, 0] if x == 1
    
    key = [n,x]
    return @memo[key] if @memo[key]
    return @memo[[n, @memomax[n]]] if @memomax[n] && @memomax[n] <= x
    
    
    total1, np1 = solve(n-1, x-1)
    return @memo[key] = [total1+1, np1] if total1 >= x-1
    total2, np2 = solve(n-1, x-1-total1-1)
    return @memo[key] = [total2+1+total1+1, np2+1+np1] if total2 >= x-1-total1-1
    
    t = 1+total2+1+total1+1
    @memomax[n] = t
    return @memo[[n, t]] = [t, np2+1+np1]
end


p solve(*ascan)[1]