K = int(input())
now = 7
for i in range(K):
    if now % K == 0:
        print(i + 1)
        exit(0)
    now = (10 * now + 7) % K
print("-1") K = int(input()) K int(input()) int input() input now = 7 now 7 for i in range(K):
    if now % K == 0:
        print(i + 1)
        exit(0)
    now = (10 * now + 7) % K i range(K) range K if now % K == 0:
        print(i + 1)
        exit(0)
     now % K == 0 now % K now K 0 print(i + 1) print i + 1 i 1 exit(0) exit 0 now = (10 * now + 7) % K now (10 * now + 7) % K 10 * now + 7 10 * now 10 now 7 K print("-1") print "-1" now = (10 * now + 7) % K (10 * now + 7) % K now now = 7 7 now K = int(input()) int(input()) K
K = int(input())
now = 7
for i in range(K):
    if now % K == 0:
        print(i + 1)
        exit(0)
    now = (10 * now + 7) % K
print("-1")
