main = do
  li <- getLine
  let ans = compute $ read li
  print ans

compute :: Int -> Int
compute n | even n || mod n 5 == 0 = -1
compute n = loop n 1 (mod 7 n)

loop n c 0 = c
loop n c m = loop n (succ c) (mod (m*10+7) n)
