main :: IO ()
main = do
	[k, s] <- (map read . words) <$> getLine
	putStrLn $ show $ solve k s

solve :: Int -> Int -> Int
solve k s = length [x | x <- [0..k], y <- [0..k], z<- [0..k], x + y + z == s]