import Control.Monad

getTrio n x = [(a, b, c) | a <- [1..n], b <- [a..n], c <- [b..n], a < b, b < c, a + b + c == x]

main = do
  a <- return . filter (/= [0, 0]) . map toIntList . lines =<< getContents
  mapM_ (print . length) $ map (\[n, x] -> getTrio n x) a