import           Control.Monad
import           Data.IORef
import           Data.List.Split
import           Data.Maybe
import           Data.List

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

  let ls = [0 .. k]
      ans = length [0 | x <- ls, y <- ls, z <- ls, x + y + z == s]

  print ans