K = int(input())
seven_number = 0
ality = 0
for ans in range(1,10**7):
        if ans > K:
            print("-1")
            break
        else:
            seven_number = (seven_number*10+7) % K
            if seven_number ==0:
                print(ans)
                break K = int(input()) K int(input()) int input() input seven_number = 0 seven_number 0 ality = 0 ality 0 for ans in range(1,10**7):
        if ans > K:
            print("-1")
            break
        else:
            seven_number = (seven_number*10+7) % K
            if seven_number ==0:
                print(ans)
                break ans range(1,10**7) range 1 10**7 10 7 if ans > K:
            print("-1")
            break
        else:
            seven_number = (seven_number*10+7) % K
            if seven_number ==0:
                print(ans)
                break ans > K ans K print("-1") print "-1" break seven_number = (seven_number*10+7) % K seven_number (seven_number*10+7) % K seven_number*10+7 seven_number*10 seven_number 10 7 K if seven_number ==0:
                print(ans)
                break seven_number ==0 seven_number 0 print(ans) print ans break ality = 0 0 ality K = int(input()) int(input()) K seven_number = (seven_number*10+7) % K (seven_number*10+7) % K seven_number seven_number = 0 0 seven_number
K = int(input())
seven_number = 0
ality = 0
for ans in range(1,10**7):
        if ans > K:
            print("-1")
            break
        else:
            seven_number = (seven_number*10+7) % K
            if seven_number ==0:
                print(ans)
                break
