main = do
  [n, x] <- fmap (map read . words) getLine
  if [n, x] == [0, 0] then return ()
  else do
    print (length [(a,b,c) | a <- [1..n], b <- [1..n], c <- [1..n],
                             (a+b+c == x) && ((a < b) && (b < c))])
    main