import           Control.Applicative
import           Control.Monad
import           Data.List.Split

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

main :: IO ()
main = do
  input <- getLine
  let nums = map read (splitOn " " input) :: [Int]
  print $ getResult (head nums) (last nums)
