loop do
  n, x = gets.split.map(&:to_i)
  break if n == 0 && x == 0
  c = 0
  n.downto (x + 3) / 3 do |i|
    (i-1).downto (x - i + 1) / 2 do |j|
      k = x - (i + j)
      c += 1 if 1 <= k && k < j
    end
  end
  p c
end