k = int(input())
ans = -1
prev = 0
for i in range(1, k + 1):
    prev = (10 * prev + 7) % k
    if prev == 0:
        ans = i
        break
print(ans) k = int(input()) k int(input()) int input() input ans = -1 ans -1 prev = 0 prev 0 for i in range(1, k + 1):
    prev = (10 * prev + 7) % k
    if prev == 0:
        ans = i
        break i range(1, k + 1) range 1 k + 1 k 1 prev = (10 * prev + 7) % k prev (10 * prev + 7) % k 10 * prev + 7 10 * prev 10 prev 7 k if prev == 0:
        ans = i
        break prev == 0 prev 0 ans = i ans i break print(ans) print ans k = int(input()) int(input()) k prev = (10 * prev + 7) % k (10 * prev + 7) % k prev prev = 0 0 prev ans = i i ans ans = -1 -1 ans
k = int(input())
ans = -1
prev = 0
for i in range(1, k + 1):
    prev = (10 * prev + 7) % k
    if prev == 0:
        ans = i
        break
print(ans)