main :: IO ()
main = do
  k <- readLn :: IO Integer
  print $ fst $ solve k (1, 0)

solve :: Integer -> (Integer, Integer) -> (Integer, Integer)
solve k (i, x)
  | k `mod` 2 == 0 = (-1, 0)
  | otherwise =
    if tmp == 0
      then (i, x)
      else solve k ((i + 1), tmp)
  where
    tmp = (10 * x + 7) `mod` k