import Data.List
import Control.Applicative

main = do
  [k,s] <- map read . words <$> getLine
  print $ sum $ (`map` [0..min k s])
   $ \ !x -> max 0 $ 1 + min k (s-x) - max 0 (s-x-k)
                