import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List

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

main = do
    getContents >>= mapM_ print . map f . takeWhile (any (/=0)) . map (map read . words) .lines  