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