module Main where

import Data.Char (isSpace)
import Data.Maybe (fromJust)
import Data.List (unfoldr, nub)
import qualified Data.ByteString.Char8 as BS


main :: IO ()
main = do
  [k,s] <- readIntList . head <$> plainInputs
  print $ length $ nub $ filter (bounds s) $ tiles k s
  where
    bounds s (x,y,z) = x + y + z == s

tiles :: Int -> Int -> [(Int,Int,Int)]
tiles k s = do
  x <- [0..lim s]
  y <- [0..lim (s-x)]
  pure (x,y,min (s-x-y) k)
  where
    lim a = min a k


-- utils
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

readIntList :: BS.ByteString -> [Int]
readIntList = unfoldr (BS.readInt . BS.dropWhile isSpace)

plainInputs :: IO [BS.ByteString]
plainInputs = BS.lines <$> BS.getContents
