# ABC174 C

K=int(input())

res=1
r=7%K
flg=(K%2==0 or K%5==0)
if flg:
    res=-1
while not flg:
    if not r:
        break
    r=(10*r+7)%K
    res+=1
print(res) K=int(input()) K int(input()) int input() input res=1 res 1 r=7%K r 7%K 7 K flg=(K%2==0 or K%5==0) flg K%2==0 or K%5==0 K%2==0 K%2 K 2 0 K%5==0 K%5 K 5 0 if flg:
    res=-1 flg res=-1 res -1 while not flg:
    if not r:
        break
    r=(10*r+7)%K
    res+=1 not flg flg if not r:
        break
     not r r break r=(10*r+7)%K r (10*r+7)%K 10*r+7 10*r 10 r 7 K res+=1 res 1 print(res) print res K=int(input()) int(input()) K flg=(K%2==0 or K%5==0) K%2==0 or K%5==0 flg r=7%K 7%K r r=(10*r+7)%K (10*r+7)%K r res+=1 1 res res=-1 -1 res res=1 1 res
# ABC174 C

K=int(input())

res=1
r=7%K
flg=(K%2==0 or K%5==0)
if flg:
    res=-1
while not flg:
    if not r:
        break
    r=(10*r+7)%K
    res+=1
print(res)