module Main where

getChange :: Integer -> Integer
getChange n
	| n `mod` 1000 == 0 = 0
	| otherwise = 1000 - (n `mod` 1000)

thisLine :: String -> String
thisLine ('\n':_) = ""
thisLine (x:xs) = x : thisLine xs 

main :: IO ()
main = interact $ show . getChange . read -- . thisLine
