# -*- coding: utf-8 -*-
"""
Created on Fri Aug  7 01:25:53 2020

@author: saito
"""

# %% import phase
#from collections import deque

# %% define phase


# %% input phase
K = int(input())

# %% process phase
r = 0
answer = -1
h = []

for cnt in range(K):
    r = (10*r+7) % K
    if r == 0:
        answer = cnt + 1
        break

# %%output phase
print(answer) """
Created on Fri Aug  7 01:25:53 2020

@author: saito
""" K = int(input()) K int(input()) int input() input r = 0 r 0 answer = -1 answer -1 h = [] h [] for cnt in range(K):
    r = (10*r+7) % K
    if r == 0:
        answer = cnt + 1
        break

# %%output phase cnt range(K) range K r = (10*r+7) % K r (10*r+7) % K 10*r+7 10*r 10 r 7 K if r == 0:
        answer = cnt + 1
        break

# %%output phase r == 0 r 0 answer = cnt + 1 answer cnt + 1 cnt 1 break print(answer) print answer answer = -1 -1 answer r = (10*r+7) % K (10*r+7) % K r K = int(input()) int(input()) K r = 0 0 r h = [] [] h answer = cnt + 1 cnt + 1 answer
# -*- coding: utf-8 -*-
"""
Created on Fri Aug  7 01:25:53 2020

@author: saito
"""

# %% import phase
#from collections import deque

# %% define phase


# %% input phase
K = int(input())

# %% process phase
r = 0
answer = -1
h = []

for cnt in range(K):
    r = (10*r+7) % K
    if r == 0:
        answer = cnt + 1
        break

# %%output phase
print(answer)