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

for i in 1..n
 for j in 1..n
  for k in 1..n
if i == j || i == k ||j == k
com += 0
else 
com += 1 unless i + j + k == x
end
end
end

puts com
com = 0
end
