k = int(input())
if k%2==0 or k%5==0:
    print(-1)
else:
    ans = 1
    res = 7
    while True:
        if res%k == 0:
            print(ans)
            break
        res = res*10+7
        res %= k
        ans += 1 k = int(input()) k int(input()) int input() input if k%2==0 or k%5==0:
    print(-1)
else:
    ans = 1
    res = 7
    while True:
        if res%k == 0:
            print(ans)
            break
        res = res*10+7
        res %= k
        ans += 1 k%2==0 or k%5==0 k%2==0 k%2 k 2 0 k%5==0 k%5 k 5 0 print(-1) print -1 ans = 1 ans 1 res = 7 res 7 while True:
        if res%k == 0:
            print(ans)
            break
        res = res*10+7
        res %= k
        ans += 1 True if res%k == 0:
            print(ans)
            break
         res%k == 0 res%k res k 0 print(ans) print ans break res = res*10+7 res res*10+7 res*10 res 10 7 res %= k res k ans += 1 ans 1 res %= k k res ans += 1 1 ans k = int(input()) int(input()) k res = res*10+7 res*10+7 res res = 7 7 res ans = 1 1 ans
k = int(input())
if k%2==0 or k%5==0:
    print(-1)
else:
    ans = 1
    res = 7
    while True:
        if res%k == 0:
            print(ans)
            break
        res = res*10+7
        res %= k
        ans += 1