ARGF.each do |line|
  n, x = gets.split.map(&:to_i)
  break if n == 0 && x == 0
  ary = []
  (1..n).each do |a|
    (1..n).each do |b|
      (1..n).each do |c|
        if a+b+c == x
          ary << [a,b,c]
        end
      end
    end
  end
end

puts ary.uniq.count