main :: IO ()
main = do
  k <- readLn :: IO Int
  if k `mod` 7 == 0
    then solve ((9 * k) `div` 7)
    else solve  (9 * k)

powMod :: Integral int => int -> int -> int -> int
powMod base ex _mod
  | ex == 0   = 1
  | even ex   = square (powMod base (ex `div` 2) _mod) `mod` _mod
  | otherwise = (base * (powMod base (ex - 1) _mod)) `mod` _mod
  where
    square x = x * x

solve :: Int -> IO ()
solve l
  | l `mod` 2 == 0 = print (-1)
  | l `mod` 5 == 0 = print (-1)
  | otherwise = print $ head [i | i <- [1 .. 9000000], powMod 10 i l == 1]