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

  cnt = 0
  ave = x/3
  for i in (1..ave-1)
    ave2 = (x-1)/2
    for j in (i+1..ave2)
      k = x-i-j
      if j <k && k<= n
        cnt += 1
      end
    end
end

puts (cnt)
end