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

puts com.count