import qualified Data.ByteString.Char8 as BS
import Data.Maybe
 
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
 
getInt = readInt <$> BS.getLine
 
main = do
  n <- getInt
  print $ n `mod` 1000