import Data.List
import Control.Applicative

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