modPow :: Integral a => a -> a -> a -> a modPow _ _ 0 = 1 modPow m x n = (x * modPow m x (n - 1)) `mod` m solve :: Integral a => a -> a solve m = (2017 + modPow m (2017 * 2017) 2017) `mod` m main = do m <- readLn print $ solve m