# def div(n):

#     ans = []

#     for i in range(1,int(n**(1/2)+2)):

#         if n%i == 0:

#             ans.append(i)

#             ans.append(n//i)

#     ans = set(ans)

#     return ans



k = int(eval(input()))

# print(div(k))

a = 7

if k % 2 == 0:

    print((-1))

    exit()

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

    if a%k == 0:

        print(i)

        exit()

    a=a*10+7

    a=a%k

print((-1))

# print(div(k))

# def div(n):

#     ans = []

#     for i in range(1,int(n**(1/2)+2)):

#         if n%i == 0:

#             ans.append(i)

#             ans.append(n//i)

#     ans = set(ans)

#     return ans



k = int(eval(input()))

# print(div(k))

a = 7

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

    if a%k == 0:

        print(i)

        exit()

    a=a*10+7

    a %= k

print((-1))

# print(div(k))

# def div(n):
#     ans = []
#     for i in range(1,int(n**(1/2)+2)):
#         if n%i == 0:
#             ans.append(i)
#             ans.append(n//i)
#     ans = set(ans)
#     return ans
k = int(eval(input()))
# print(div(k))
a = 7
if k % 2 == 0:
    print((-1))
    exit()
for i in range(1, 10**8 + 2):
    if a % k == 0:
        print(i)
        exit()
    a = a * 10 + 7
    a = a % k
print((-1))
# print(div(k))

# def div(n):
#     ans = []
#     for i in range(1,int(n**(1/2)+2)):
#         if n%i == 0:
#             ans.append(i)
#             ans.append(n//i)
#     ans = set(ans)
#     return ans
k = int(eval(input()))
# print(div(k))
a = 7
for i in range(1, 10**7 + 2):
    if a % k == 0:
        print(i)
        exit()
    a = a * 10 + 7
    a %= k
print((-1))
# print(div(k))

-if k % 2 == 0: -    print((-1)) -    exit() -for i in range(1, 10**8 + 2): +for i in range(1, 10**7 + 2): -    a = a % k +    a %= k