ans 2 t =
  if t > 2000
  then 0
  else if t > 1000
       then 2001 - t
       else t + 1

ans n t =
    if t > n * 1000
    then 0
    else
        let m = min t 1000
        in
            sum $ map (\i -> ans (n-1) (t-i)) [0..m]

main = do
  c <- getContents
  let i = map read $ lines c :: [Int]
      o = map (ans 4) i
  mapM_ print o
