K=int(input())
nana=[7]
for i in range(0,K):
    if nana[i]%K==0:
        print(i+1)
        break
    nana.append((nana[i]*10+7)%K)
    if i==K-1:
        print("-1")
        break K=int(input()) K int(input()) int input() input nana=[7] nana [7] 7 for i in range(0,K):
    if nana[i]%K==0:
        print(i+1)
        break
    nana.append((nana[i]*10+7)%K)
    if i==K-1:
        print("-1")
        break i range(0,K) range 0 K if nana[i]%K==0:
        print(i+1)
        break
     nana[i]%K==0 nana[i]%K nana[i] nana i K 0 print(i+1) print i+1 i 1 break nana.append((nana[i]*10+7)%K) nana.append nana append (nana[i]*10+7)%K nana[i]*10+7 nana[i]*10 nana[i] nana i 10 7 K if i==K-1:
        print("-1")
        break i==K-1 i K-1 K 1 print("-1") print "-1" break nana=[7] [7] nana K=int(input()) int(input()) K
K=int(input())
nana=[7]
for i in range(0,K):
    if nana[i]%K==0:
        print(i+1)
        break
    nana.append((nana[i]*10+7)%K)
    if i==K-1:
        print("-1")
        break