

while true
 n, x = gets.split.map(&:to_i)
break if n == 0 && x == 0 
com = 0

loop do
for i in 1..n
 for j in 1..n
  for k in 1..n
if i == j || i == k ||j == k
com += 0
elsif i + j + k == x
com += 1 
break if i + j + k < x
end
end
end
end
end

puts com
end
