main :: IO ()
main = do
  k <- read <$> getLine
  if k `mod` 2 == 0 || k `mod` 5 == 0
    then print (-1)
    else do
      let sevens =
            iterate (\(a, i) -> ((a * 10 + 7) `mod` k, i + 1)) (7 `mod` k, 1)
      let Just answer = lookup 0 sevens
      print $ answer
      return ()
