while true
    numbers = gets.split.map(&:to_i)
    count = 0
    if numbers[0] == 0 && numbers[1] == 0
        break
    else
        (1..numbers[0]).each do |t|
            (1..t-1).each do |t_micro|
                (1..t_micro-1).each do |t_micro_2|
                    if t+t_micro+t_micro_2 == numbers[1]
                        count += 1
                    end
                end
            end
        end
    end
    puts count
end
