K = int(input())

extra = 7 % K

#あまり0と出会う前にが同じあまりのものと合うと終わりなのでそれをチェック。
seen = set()
ans = 1

while extra not in seen:
    if extra == 0:
        print(ans)
        exit()
    seen.add(extra)
    extra = (extra*10 + 7) % K
    ans += 1
print(-1)     K = int(input()) K int(input()) int input() input extra = 7 % K extra 7 % K 7 K seen = set() seen set() set ans = 1 ans 1 while extra not in seen:
    if extra == 0:
        print(ans)
        exit()
    seen.add(extra)
    extra = (extra*10 + 7) % K
    ans += 1 extra not in seen extra seen if extra == 0:
        print(ans)
        exit()
     extra == 0 extra 0 print(ans) print ans exit() exit seen.add(extra) seen.add seen add extra extra = (extra*10 + 7) % K extra (extra*10 + 7) % K extra*10 + 7 extra*10 extra 10 7 K ans += 1 ans 1 print(-1) print -1 K = int(input()) int(input()) K seen = set() set() seen ans = 1 1 ans extra = 7 % K 7 % K extra extra = (extra*10 + 7) % K (extra*10 + 7) % K extra ans += 1 1 ans
K = int(input())

extra = 7 % K

#あまり0と出会う前にが同じあまりのものと合うと終わりなのでそれをチェック。
seen = set()
ans = 1

while extra not in seen:
    if extra == 0:
        print(ans)
        exit()
    seen.add(extra)
    extra = (extra*10 + 7) % K
    ans += 1
print(-1)    