k=int(input())
num=0
for i in range(k+1):
    num=(num*10+7)%k
    if num==0:
        print(i+1)
        break
if num:
    print("-1") k=int(input()) k int(input()) int input() input num=0 num 0 for i in range(k+1):
    num=(num*10+7)%k
    if num==0:
        print(i+1)
        break i range(k+1) range k+1 k 1 num=(num*10+7)%k num (num*10+7)%k num*10+7 num*10 num 10 7 k if num==0:
        print(i+1)
        break num==0 num 0 print(i+1) print i+1 i 1 break if num:
    print("-1") num print("-1") print "-1" num=(num*10+7)%k (num*10+7)%k num num=0 0 num k=int(input()) int(input()) k
k=int(input())
num=0
for i in range(k+1):
    num=(num*10+7)%k
    if num==0:
        print(i+1)
        break
if num:
    print("-1")