let () = Scanf.scanf "%d\n" @@ fun k ->
  let rec solve i x =
    if x = 0
    then i
    else if k < i
    then -1
    else solve (i + 1) ((10 * x + 7) mod k) in
  Printf.printf "%d\n" @@ solve 1 (7 mod k)