ma = lambda :map(int,input().split())

ni = lambda:int(input())

yn = lambda fl:print("Yes") if fl else print("No")

import collections

import math

import itertools

import heapq as hq

k = ni()

a = 0

for i in range(10**6):

    a=(a+7*pow(10,i,k))%k

    if a== 0:

        print(i+1)

        break

else:

    print(-1)

ma = lambda :map(int,input().split())

ni = lambda:int(input())

yn = lambda fl:print("Yes") if fl else print("No")

import collections

import math

import itertools

import heapq as hq

k = ni()



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

    print(-1)

    exit()

if k%7==0:

    L=9*k//7

else:

    L=9*k

tmp=1

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

    tmp = tmp*10 %L

    if tmp==1:

        print(i)

        break

else:

    print(-1)

ma = lambda: map(int, input().split())
ni = lambda: int(input())
yn = lambda fl: print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

k = ni()
a = 0
for i in range(10**6):
    a = (a + 7 * pow(10, i, k)) % k
    if a == 0:
        print(i + 1)
        break
else:
    print(-1)

ma = lambda: map(int, input().split())
ni = lambda: int(input())
yn = lambda fl: print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

k = ni()
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()
if k % 7 == 0:
    L = 9 * k // 7
else:
    L = 9 * k
tmp = 1
for i in range(1, 10**6):
    tmp = tmp * 10 % L
    if tmp == 1:
        print(i)
        break
else:
    print(-1)

-a = 0 -for i in range(10**6): -    a = (a + 7 * pow(10, i, k)) % k -    if a == 0: -        print(i + 1) +if k % 2 == 0 or k % 5 == 0: +    print(-1) +    exit() +if k % 7 == 0: +    L = 9 * k // 7 +else: +    L = 9 * k +tmp = 1 +for i in range(1, 10**6): +    tmp = tmp * 10 % L +    if tmp == 1: +        print(i)