count = 0
ans = []
xmax = []
num = []

loop do

 prexmax, prenum = gets.split.map &:to_i

 if !( prexmax == 0 && prenum == 0 )
  xmax << prexmax
  num << prenum
  count += 1

 else
  break
 end

end

for c in 0..count-1

 preans = 0

 imax = [num[c]/3-1, xmax[c]].min
 for i in 1..imax

  jmax = [((num[c]-i)/2.to_f).ceil-1, xmax[c]].min
  for j in i+1..jmax

   if num[c]-i-j <= xmax[c] then preans += 1 end

  end
 end

 ans << preans

end

puts ans

