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

for i in 1..n
 for j in 1..(n - 1)
  for k in 1.. (n - 2)

if i + j + k == x
com += 1 
else 
com += 0
end

end
end
end

puts com
end
