def ways(number, sum, max)
  return 0 if max <= 0 || sum <= 0
  return max >= sum ? 1 : 0 if number == 1
  min_variation = sum / number 
  return 0 if min_variation == 0
  result = 0
  (1..min_variation).each do |i|
    result += ways(number - 1, sum - i * number, max - i)
  end
  result 
end

while true
  n, x = gets.split(" ").map(&:to_i)
  break if n == 0 && x == 0
  puts ways(3, x, n)
end