while true
    n,x = gets.split.map(&:to_i)
    sum = 0
    if n==0 && x==0 then break end

    for i in 1...n
        for j in (i+1)...(x-i)
            k = x-i-j
            if j < k && k <= n then sum += 1 end
        end
    end
    puts sum
end