K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    i = 1
    r = 7 % K
    while(True):
        if r == 0:
            print(i)
            break
        r = (r * 10 + 7) % K
        i += 1 K = int(input()) K int(input()) int input() input if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    i = 1
    r = 7 % K
    while(True):
        if r == 0:
            print(i)
            break
        r = (r * 10 + 7) % K
        i += 1 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 i = 1 i 1 r = 7 % K r 7 % K 7 K while(True):
        if r == 0:
            print(i)
            break
        r = (r * 10 + 7) % K
        i += 1 True if r == 0:
            print(i)
            break
         r == 0 r 0 print(i) print i break r = (r * 10 + 7) % K r (r * 10 + 7) % K r * 10 + 7 r * 10 r 10 7 K i += 1 i 1 i = 1 1 i K = int(input()) int(input()) K i += 1 1 i r = 7 % K 7 % K r r = (r * 10 + 7) % K (r * 10 + 7) % K r
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    i = 1
    r = 7 % K
    while(True):
        if r == 0:
            print(i)
            break
        r = (r * 10 + 7) % K
        i += 1
