# Respect
K = int(input())
ans = 0
rem = 0
for i in range(K):
    rem = (10*rem + 7)%K
    if rem == 0:
        print(ans+1)
        quit()
    ans += 1
print(-1)
29064a5ec169da358ac9a44c839d1a1818bc6490
<mask token>

<mask token>
for i in range(K):
    rem = (10 * rem + 7) % K
    if rem == 0:
        print(ans + 1)
        quit()
    ans += 1
print(-1)

K = int(input())
ans = 0
rem = 0
for i in range(K):
    rem = (10 * rem + 7) % K
    if rem == 0:
        print(ans + 1)
        quit()
    ans += 1
print(-1)

# Respect
K = int(input())
ans = 0
rem = 0
for i in range(K):
    rem = (10*rem + 7)%K
    if rem == 0:
        print(ans+1)
        quit()
    ans += 1
print(-1)