import Control.Applicative
main = do
    ns <- fmap (read :: String -> Int) . words <$> getLine
    let n = ns !! 0
        x = ns !! 1
    if n == 0 && x == 0
        then return ()
        else do
            putStrLn $ show $ combi n x
            main

combi :: Int -> Int -> Int
combi n a = length $ [(x, y, z) | x <- [1..n], y <- [1..n], z <- [1..n], x < y && y < z, x + y + z == a]