k=int(eval(input()))

ama=[0]*(k)

now=7

if now%k==0:

  print((1))

  exit()

else:

  ama[now%k]+=1

for _ in range(2*k):

  now=(now*10+7)%k

  if now%k==0:

    print((_+2))

    exit()

  elif ama[now%k]==0:

    ama[now%k]+=1

  else:

    print((-1))

    exit()

    

    
k=int(eval(input()))

ama=[0]*(k)

now=7%k

ama[now]+=1

if now==0:

  print((1))

  exit()

for i in range(2,k+1):

  now=(10*now+7)%k

  if ama[now]!=0 and now>0:

    print((-1))

    exit()

  elif now==0:

    print(i)

    exit()

  else:

    ama[now]+=1

    
k = int(eval(input()))
ama = [0] * (k)
now = 7
if now % k == 0:
    print((1))
    exit()
else:
    ama[now % k] += 1
for _ in range(2 * k):
    now = (now * 10 + 7) % k
    if now % k == 0:
        print((_ + 2))
        exit()
    elif ama[now % k] == 0:
        ama[now % k] += 1
    else:
        print((-1))
        exit()

k = int(eval(input()))
ama = [0] * (k)
now = 7 % k
ama[now] += 1
if now == 0:
    print((1))
    exit()
for i in range(2, k + 1):
    now = (10 * now + 7) % k
    if ama[now] != 0 and now > 0:
        print((-1))
        exit()
    elif now == 0:
        print(i)
        exit()
    else:
        ama[now] += 1

-now = 7 -if now % k == 0: +now = 7 % k +ama[now] += 1 +if now == 0: -else: -    ama[now % k] += 1 -for _ in range(2 * k): -    now = (now * 10 + 7) % k -    if now % k == 0: -        print((_ + 2)) -        exit() -    elif ama[now % k] == 0: -        ama[now % k] += 1 -    else: +for i in range(2, k + 1): +    now = (10 * now + 7) % k +    if ama[now] != 0 and now > 0: +    elif now == 0: +        print(i) +        exit() +    else: +        ama[now] += 1