K = int(input())
a = [0]
a[0] = 7 % K
for i in range(K):
    a.append((a[i]*10 + 7) % K)
    if a[i] == 0:
        print(i+1)
        exit()
print("-1") K = int(input()) K int(input()) int input() input a = [0] a [0] 0 a[0] = 7 % K a[0] a 0 7 % K 7 K for i in range(K):
    a.append((a[i]*10 + 7) % K)
    if a[i] == 0:
        print(i+1)
        exit() i range(K) range K a.append((a[i]*10 + 7) % K) a.append a append (a[i]*10 + 7) % K a[i]*10 + 7 a[i]*10 a[i] a i 10 7 K if a[i] == 0:
        print(i+1)
        exit() a[i] == 0 a[i] a i 0 print(i+1) print i+1 i 1 exit() exit print("-1") print "-1" K = int(input()) int(input()) K a = [0] [0] a
K = int(input())
a = [0]
a[0] = 7 % K
for i in range(K):
    a.append((a[i]*10 + 7) % K)
    if a[i] == 0:
        print(i+1)
        exit()
print("-1")