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
     foldl (\acc x -> acc + ans (n-1) (t-x) ) 0 [0..m]

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