K = int(input())

powlis = [7*pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K
powlis[0] %= K


try:
    print(powlis.index(0) + 1)
except:
    print(-1) K = int(input()) K int(input()) int input() input 7*pow(10, i, K) for i in range(K) for i in range(K) i range(K) range K for i in range(K) 7*pow(10, i, K) 7 pow(10, i, K) pow 10 i K powlis = [7*pow(10, i, K) for i in range(K)] powlis [7*pow(10, i, K) for i in range(K)] for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K i range(K-1) range K-1 K 1 powlis[i+1] = (powlis[i] + powlis[i+1]) % K powlis[i+1] powlis i+1 i 1 (powlis[i] + powlis[i+1]) % K powlis[i] + powlis[i+1] powlis[i] powlis i powlis[i+1] powlis i+1 i 1 K powlis[0] %= K powlis[0] powlis 0 K try:
    print(powlis.index(0) + 1)
except:
    print(-1) except:
    print(-1) print(-1) print -1 print(powlis.index(0) + 1) print powlis.index(0) + 1 powlis.index(0) powlis.index powlis index 0 1 powlis = [7*pow(10, i, K) for i in range(K)] [7*pow(10, i, K) for i in range(K)] powlis K = int(input()) int(input()) K
K = int(input())

powlis = [7*pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K
powlis[0] %= K


try:
    print(powlis.index(0) + 1)
except:
    print(-1)