import Data.Maybe (fromJust)
import Data.List  (elemIndex)

main :: IO ()
main = do
  k <- readLn :: IO Int
  if k `mod` 2 == 0 || k `mod` 5 == 0
    then print (-1)
    else print $ succ $ fromJust $ elemIndex 0 $ iterate (\i -> (i * 10 + 7) `rem` k) (7 `rem` k)