K = int(input())
tmp = 1
ans = -1

if K % 7 == 0:
    L = 9 * K // 7
else:
    L = 9 * K

for i in range(10 ** 7):
    tmp *= 10
    tmp = tmp % L
    if tmp == 1:
        ans = i + 1
        break
   
print(ans) K = int(input()) K int(input()) int input() input tmp = 1 tmp 1 ans = -1 ans -1 if K % 7 == 0:
    L = 9 * K // 7
else:
    L = 9 * K K % 7 == 0 K % 7 K 7 0 L = 9 * K // 7 L 9 * K // 7 9 * K 9 K 7 L = 9 * K L 9 * K 9 K for i in range(10 ** 7):
    tmp *= 10
    tmp = tmp % L
    if tmp == 1:
        ans = i + 1
        break
    i range(10 ** 7) range 10 ** 7 10 7 tmp *= 10 tmp 10 tmp = tmp % L tmp tmp % L tmp L if tmp == 1:
        ans = i + 1
        break
    tmp == 1 tmp 1 ans = i + 1 ans i + 1 i 1 break print(ans) print ans L = 9 * K // 7 9 * K // 7 L tmp = 1 1 tmp ans = -1 -1 ans L = 9 * K 9 * K L tmp *= 10 10 tmp tmp = tmp % L tmp % L tmp K = int(input()) int(input()) K ans = i + 1 i + 1 ans
K = int(input())
tmp = 1
ans = -1

if K % 7 == 0:
    L = 9 * K // 7
else:
    L = 9 * K

for i in range(10 ** 7):
    tmp *= 10
    tmp = tmp % L
    if tmp == 1:
        ans = i + 1
        break
   
print(ans)