import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Vector.Unboxed as Vec
import Debug.Trace as De

--getIntList = map read . words <$> getLine


listToTriple abc =(a,b,c)
    where [a,b,c]=abc
main :: IO ()

fir (a,_,_)=a
sec (_,b,_)=b
trd (_,_,c)=c

solve:: Int->Int->Int ->Int
solve k x ans
    |(x `mod` k) == 0  = ans
    |ans>(k+10) = -1
    |otherwise = (solve k ((x*10+7) `mod` k) (ans+1))

main = do
    input <- getLine
    let k=(read input)
    putStrLn(show(solve k 7 1))



    

