points = []
while true
  line = STDIN.gets.chomp
  if line == "0 0" then break end
  point = Array.new(2) { |i|  i = line.split(" ")[i].to_i}
  points << point
end

# print points

points.each do |point|
  output = 0
  for i in 1..point[0] - 1 do
    for j in i+1..point[1] do
      # print "i = #{i}, j = #{j}\n"
      num = point[1] - i - j;
      if num > 0 && num <= point[0] && num > j then
        # puts "success! i = #{i}, j = #{j}, num = #{num}"
        output += 1
      end
    end
  end
  puts output
end