open Printf
open Scanf

let id x = x

let k = scanf "%d" (fun k -> k)

let rec run v k n =
    if v mod k = 0 then n
    else if v < k then run (v * 10 + 7) k (n + 1)
    else run (v mod k) k n

let () =
    if k mod 2 = 0 then print_endline "-1"
    else if k mod 5 = 0 then print_endline "-1"
    else printf "%d\n" (run 7 k 1)
