import sys
K = int(input())
ans = 0
cur = 0
for i in range(10**6):
    cur += (7 * pow(10, i, K))%K
    if cur % K == 0:
        print(i+1)
        sys.exit()
    cur %= K
print(-1) import sys sys K = int(input()) K int(input()) int input() input ans = 0 ans 0 cur = 0 cur 0 for i in range(10**6):
    cur += (7 * pow(10, i, K))%K
    if cur % K == 0:
        print(i+1)
        sys.exit()
    cur %= K i range(10**6) range 10**6 10 6 cur += (7 * pow(10, i, K))%K cur (7 * pow(10, i, K))%K 7 * pow(10, i, K) 7 pow(10, i, K) pow 10 i K K if cur % K == 0:
        print(i+1)
        sys.exit()
     cur % K == 0 cur % K cur K 0 print(i+1) print i+1 i 1 sys.exit() sys.exit sys exit cur %= K cur K print(-1) print -1 ans = 0 0 ans K = int(input()) int(input()) K cur = 0 0 cur cur %= K K cur cur += (7 * pow(10, i, K))%K (7 * pow(10, i, K))%K cur
import sys
K = int(input())
ans = 0
cur = 0
for i in range(10**6):
    cur += (7 * pow(10, i, K))%K
    if cur % K == 0:
        print(i+1)
        sys.exit()
    cur %= K
print(-1)