let k = stdin.ReadLine() |> int64

let rec repsept a count =
    if count > k then -1L
    else 
        let a' = (a * 10L + 7L) % k
        if a'= 0L then count
        else repsept a' (count+1L)

repsept 0L 1L |> stdout.WriteLine