k=int(eval(input()))

ans='-1'

a=7

for i in range(1,10**6+1):

  if a%k==0:

    ans=i

    break



  a=((10*a)+7)%k

    

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

if k%2==0:

  print((-1))

  exit()

  

ans=1

pin=7

mod=k



for i in range(1000000):

  if pin%k==0:

    print(ans)

    exit()

    

  ans+=1

  pin*=10

  pin+=7

  pin%=mod

  



print('-1')

  
k = int(eval(input()))
ans = "-1"
a = 7
for i in range(1, 10**6 + 1):
    if a % k == 0:
        ans = i
        break
    a = ((10 * a) + 7) % k
print(ans)

k = int(eval(input()))
if k % 2 == 0:
    print((-1))
    exit()
ans = 1
pin = 7
mod = k
for i in range(1000000):
    if pin % k == 0:
        print(ans)
        exit()
    ans += 1
    pin *= 10
    pin += 7
    pin %= mod
print("-1")

-ans = "-1" -a = 7 -for i in range(1, 10**6 + 1): -    if a % k == 0: -        ans = i -        break -    a = ((10 * a) + 7) % k -print(ans) +if k % 2 == 0: +    print((-1)) +    exit() +ans = 1 +pin = 7 +mod = k +for i in range(1000000): +    if pin % k == 0: +        print(ans) +        exit() +    ans += 1 +    pin *= 10 +    pin += 7 +    pin %= mod +print("-1")