rekkyo :: Integer -> Integer -> [(Integer,Integer)]
rekkyo n k = [(x,y)|(x,y) <- doubles n,check(x,y,k,n)]

doubles :: Integer -> [(Integer,Integer)]
doubles n = [(x,y)|x <- [0..n],y <- [0..n]]

check :: (Integer,Integer,Integer,Integer) -> Bool
check(x,y,k,n) =((0 <= k-x-y) && (k-x-y <= n))

main = do
    [n,k] <- map read . words <$> getLine
    let res = rekkyo n k 
    print (length res)