import Data.List

main = getContents >>= putOut.formatOut.calc.formatIn
  where putOut s | null s || last s == '\n' = putStr s
                 | otherwise                = putStrLn s
  
formatIn :: String -> [[Int]]
formatIn =  map ((map (read :: String -> Int)).words).takeWhile (/= "0 0").lines

formatOut :: [Int] -> String
formatOut = unlines.map show

calc :: [[Int]] -> [Int]
calc n = map (\(x:y:_) -> length[(a, b, c) | a <- [1..x], b <- [a..x], c <- [b..x], a < b, b < c, a + b + c == y]) n