cnt = 0
loop do
    input = gets.split(" ").map do |i| i.to_i end
    while input[0] != 0 && input[1] != 0
        (1..input[0]).each do |n1|
            (2..input[0]).each do |n2|
                (3..input[0]).each do |n3|
                    if n1 + n2 + n3 == input[1]
                        cnt += 1
                    end
                end
            end
        end
    end
end

puts cnt