K  = int(input())
a = 0

for i in range(K):
    a = (10 * a + 7) % K
    if a % K == 0:
        print(i+1)
        exit()
    else:
        a %= K

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

for i in range(K):
    a = (10 * a + 7) % K
    if a % K == 0:
        print(i+1)
        exit()
    else:
        a %= K

print(-1)
