K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()
now = 0
count = 0
while True:
    now = (now * 10 + 7) % K
    count += 1
    if now % K == 0:
        print(count)
        exit() K = int(input()) K int(input()) int input() input if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit() K % 2 == 0 or K % 5 == 0 K % 2 == 0 K % 2 K 2 0 K % 5 == 0 K % 5 K 5 0 print(-1) print -1 exit() exit now = 0 now 0 count = 0 count 0 while True:
    now = (now * 10 + 7) % K
    count += 1
    if now % K == 0:
        print(count)
        exit() True now = (now * 10 + 7) % K now (now * 10 + 7) % K now * 10 + 7 now * 10 now 10 7 K count += 1 count 1 if now % K == 0:
        print(count)
        exit() now % K == 0 now % K now K 0 print(count) print count exit() exit count = 0 0 count now = (now * 10 + 7) % K (now * 10 + 7) % K now count += 1 1 count K = int(input()) int(input()) K now = 0 0 now
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()
now = 0
count = 0
while True:
    now = (now * 10 + 7) % K
    count += 1
    if now % K == 0:
        print(count)
        exit()
