import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  k <- unsafeTextToInt <$> T.getLine :: IO Int
  let
    xs = iterate ((`mod` k) . (7 +) . (10 *)) (7 `mod` k) :: [Int]
  print $ if k `mod` 2 == 0 || k `mod` 5 == 0 then -1 else succ . length . takeWhile (/= 0) $ xs

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
