k=int(input())

if (k%2)*(k%5)<1: exit(print(-1))

a,t,m=1,7,7

while m%k:

  a+=1

  t=t*10%k

  m+=t

print(a)

k=int(input())

t=7

for i in range(k):

  if t%k<1: exit(print(i+1))

  t=(t*10+7)%k

print(-1)

k = int(input())
if (k % 2) * (k % 5) < 1:
    exit(print(-1))
a, t, m = 1, 7, 7
while m % k:
    a += 1
    t = t * 10 % k
    m += t
print(a)

k = int(input())
t = 7
for i in range(k):
    if t % k < 1:
        exit(print(i + 1))
    t = (t * 10 + 7) % k
print(-1)

-if (k % 2) * (k % 5) < 1: -    exit(print(-1)) -a, t, m = 1, 7, 7 -while m % k: -    a += 1 -    t = t * 10 % k -    m += t -print(a) +t = 7 +for i in range(k): +    if t % k < 1: +        exit(print(i + 1)) +    t = (t * 10 + 7) % k +print(-1)