main = do
    str <- getLine
    let (n:x:_) = map read $ words str
    if ((n,x) == (0,0)) then
        return ()
    else do
        print $ foldr (\_ x -> x+1) 0 [1 | a <- [1..(n-2)], b <- [(a+1)..(n-1)], c <- [(b+1)..(min (n) (x-a-b))], a+b+c==x]
        main