Scanf.scanf "%d" (fun k ->
    let calc k =
        let rec loop i cur =
            let cur = cur mod k in
            if cur = 0 then i else loop (i + 1) (cur * 10 + 7)
        in
        loop 1 7
    in
    let ans = if k mod 2 = 0 || k mod 5 = 0 then -1 else calc k in
    Printf.printf "%d\n" ans
)