main :: IO ()
main = do
    [k,s] <- map read . words <$> getLine
    print . length $ xyzs k s

xyzs :: Int -> Int -> [(Int, Int, Int)]
xyzs k s = [(x,y,z) | x <- [0..k], y <- [0..k], z <- [0..k], x+y+z == s]