K = int(input())

i = 7 % K

result = set()
for x in range(K):
    if i == 0:
        print(x + 1)
        exit()
    if i in result:
        print(-1)
        exit()
    else:
        result.add(i)

    i = (i * 10 + 7) % K

print(-1) K = int(input()) K int(input()) int input() input i = 7 % K i 7 % K 7 K result = set() result set() set for x in range(K):
    if i == 0:
        print(x + 1)
        exit()
    if i in result:
        print(-1)
        exit()
    else:
        result.add(i)

    i = (i * 10 + 7) % K x range(K) range K if i == 0:
        print(x + 1)
        exit()
     i == 0 i 0 print(x + 1) print x + 1 x 1 exit() exit if i in result:
        print(-1)
        exit()
    else:
        result.add(i)

     i in result i result print(-1) print -1 exit() exit result.add(i) result.add result add i i = (i * 10 + 7) % K i (i * 10 + 7) % K i * 10 + 7 i * 10 i 10 7 K print(-1) print -1 i = 7 % K 7 % K i i = (i * 10 + 7) % K (i * 10 + 7) % K i K = int(input()) int(input()) K result = set() set() result
K = int(input())

i = 7 % K

result = set()
for x in range(K):
    if i == 0:
        print(x + 1)
        exit()
    if i in result:
        print(-1)
        exit()
    else:
        result.add(i)

    i = (i * 10 + 7) % K

print(-1)
