# Ai ≡ 0 (mod k) A1 = 7, A2 = 77, A3 = 777

k = int(input())
if k == 7 or k == 1:
    print(1)
    exit()
# よくわからんからAiをmodKにして試してみる
seven = 7
for i in range(1, 10**6 + 10):
    seven = seven * 10 + 7
    seven %= k
    if seven == 0:
        print(i + 1)
        exit()
print(-1) k = int(input()) k int(input()) int input() input if k == 7 or k == 1:
    print(1)
    exit()
# よくわからんからAiをmodKにして試してみる k == 7 or k == 1 k == 7 k 7 k == 1 k 1 print(1) print 1 exit() exit seven = 7 seven 7 for i in range(1, 10**6 + 10):
    seven = seven * 10 + 7
    seven %= k
    if seven == 0:
        print(i + 1)
        exit() i range(1, 10**6 + 10) range 1 10**6 + 10 10**6 10 6 10 seven = seven * 10 + 7 seven seven * 10 + 7 seven * 10 seven 10 7 seven %= k seven k if seven == 0:
        print(i + 1)
        exit() seven == 0 seven 0 print(i + 1) print i + 1 i 1 exit() exit print(-1) print -1 seven = 7 7 seven seven = seven * 10 + 7 seven * 10 + 7 seven k = int(input()) int(input()) k seven %= k k seven
# Ai ≡ 0 (mod k) A1 = 7, A2 = 77, A3 = 777

k = int(input())
if k == 7 or k == 1:
    print(1)
    exit()
# よくわからんからAiをmodKにして試してみる
seven = 7
for i in range(1, 10**6 + 10):
    seven = seven * 10 + 7
    seven %= k
    if seven == 0:
        print(i + 1)
        exit()
print(-1)