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

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

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

end
end
end

puts com
end
