#数列が与えられたら漸化式を作る
#a1 = 7, ai = 10 * a(i - 1) + 7 (i >= 2)
K = int(input())
a = [7 % K] #a1 mod K
for i in range(K - 1): #a2 - aK
  a.append((10 * a[i] + 7) % K) #mod K
for i in range(K):
  if a[i] == 0:
    print(i + 1)
    break
else: print(-1) K = int(input()) K int(input()) int input() input a = [7 % K] a [7 % K] 7 % K 7 K for i in range(K - 1): #a2 - aK
  a.append((10 * a[i] + 7) % K) #mod K i range(K - 1) range K - 1 K 1 a.append((10 * a[i] + 7) % K) a.append a append (10 * a[i] + 7) % K 10 * a[i] + 7 10 * a[i] 10 a[i] a i 7 K for i in range(K):
  if a[i] == 0:
    print(i + 1)
    break
else: print(-1) i range(K) range K if a[i] == 0:
    print(i + 1)
    break a[i] == 0 a[i] a i 0 print(i + 1) print i + 1 i 1 break K = int(input()) int(input()) K a = [7 % K] [7 % K] a
#数列が与えられたら漸化式を作る
#a1 = 7, ai = 10 * a(i - 1) + 7 (i >= 2)
K = int(input())
a = [7 % K] #a1 mod K
for i in range(K - 1): #a2 - aK
  a.append((10 * a[i] + 7) % K) #mod K
for i in range(K):
  if a[i] == 0:
    print(i + 1)
    break
else: print(-1)