ans 1 t =
  if 0 <= t && t <= 1000
  then 1
  else 0

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

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

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