#https://atcoder.jp/contests/abc174/tasks/abc174_c
K= int(input())

if K%2==0 or K%5==0:
    print(-1)
elif K==1 or K==7:
    print(1)
else:
    B = 7
    i = 1
    while 1:
        if B==0:
            print(i)
            break
        else:
            B = (10 * B + 7) % K
            i = i + 1 K= int(input()) K int(input()) int input() input if K%2==0 or K%5==0:
    print(-1)
elif K==1 or K==7:
    print(1)
else:
    B = 7
    i = 1
    while 1:
        if B==0:
            print(i)
            break
        else:
            B = (10 * B + 7) % K
            i = 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 elif K==1 or K==7:
    print(1) K==1 or K==7 K==1 K 1 K==7 K 7 print(1) print 1 B = 7 B 7 i = 1 i 1 while 1:
        if B==0:
            print(i)
            break
        else:
            B = (10 * B + 7) % K
            i = i + 1 1 if B==0:
            print(i)
            break
        else:
            B = (10 * B + 7) % K
            i = i + 1 B==0 B 0 print(i) print i break B = (10 * B + 7) % K B (10 * B + 7) % K 10 * B + 7 10 * B 10 B 7 K i = i + 1 i i + 1 i 1 i = i + 1 i + 1 i K= int(input()) int(input()) K B = 7 7 B i = 1 1 i B = (10 * B + 7) % K (10 * B + 7) % K B
#https://atcoder.jp/contests/abc174/tasks/abc174_c
K= int(input())

if K%2==0 or K%5==0:
    print(-1)
elif K==1 or K==7:
    print(1)
else:
    B = 7
    i = 1
    while 1:
        if B==0:
            print(i)
            break
        else:
            B = (10 * B + 7) % K
            i = i + 1