
K=int(input())
i=0
if K%2==0 or K%5==0:
    print('-1')

else:
    for d in range(K):
        i=(10*i+7)%K
        if i==0:
            print(d+1)
            break K=int(input()) K int(input()) int input() input i=0 i 0 if K%2==0 or K%5==0:
    print('-1')

else:
    for d in range(K):
        i=(10*i+7)%K
        if i==0:
            print(d+1)
            break 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' for d in range(K):
        i=(10*i+7)%K
        if i==0:
            print(d+1)
            break d range(K) range K i=(10*i+7)%K i (10*i+7)%K 10*i+7 10*i 10 i 7 K if i==0:
            print(d+1)
            break i==0 i 0 print(d+1) print d+1 d 1 break K=int(input()) int(input()) K i=(10*i+7)%K (10*i+7)%K i i=0 0 i

K=int(input())
i=0
if K%2==0 or K%5==0:
    print('-1')

else:
    for d in range(K):
        i=(10*i+7)%K
        if i==0:
            print(d+1)
            break
