k=int(eval(input()))



if k%2==0 or k%5==0:

  print((-1))

  exit()



num=7

num%=k

ans=1



while num!=0:

  num=10*num+7

  num%=k

  ans+=1



print(ans)
k=int(eval(input()))



if k%2==0 or k%5==0:

  print((-1))

  exit()



ans=1

num=7%k



while num!=0:

  num=(10*num+7)%k

  ans+=1



print(ans)
k = int(eval(input()))
if k % 2 == 0 or k % 5 == 0:
    print((-1))
    exit()
num = 7
num %= k
ans = 1
while num != 0:
    num = 10 * num + 7
    num %= k
    ans += 1
print(ans)

k = int(eval(input()))
if k % 2 == 0 or k % 5 == 0:
    print((-1))
    exit()
ans = 1
num = 7 % k
while num != 0:
    num = (10 * num + 7) % k
    ans += 1
print(ans)

-num = 7 -num %= k +num = 7 % k -    num = 10 * num + 7 -    num %= k +    num = (10 * num + 7) % k