import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

main = do
    k <- fst . fromJust . BS.readInt <$> BS.getLine
    print $ answer k

answer k
    | even k = -1
    | mod k 7 == 0 = fst.head $ filter (judge k') $ nines k'
    | otherwise = fst.head $ filter (judge k'') $ nines k''
    where
        k' = 9*div k 7
        k'' = 9*k

judge k (_,nine) = mod nine k == 0

nines k = zip [1..] . scanl1 (\a b -> mod (a*10+b) k) $ repeat 9