import sys
input = sys.stdin.readline

def main():
    K = int(input())

    t = 7
    t %= K
    for i in range(K+1):
        if t == 0:
            print(i+1)
            break
        t = (t * 10 + 7) % K
    else:
        print(-1)
    

main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    K = int(input())

    t = 7
    t %= K
    for i in range(K+1):
        if t == 0:
            print(i+1)
            break
        t = (t * 10 + 7) % K
    else:
        print(-1)
     main K = int(input()) K int(input()) int input() input t = 7 t 7 t %= K t K for i in range(K+1):
        if t == 0:
            print(i+1)
            break
        t = (t * 10 + 7) % K
    else:
        print(-1)
     i range(K+1) range K+1 K 1 if t == 0:
            print(i+1)
            break
         t == 0 t 0 print(i+1) print i+1 i 1 break t = (t * 10 + 7) % K t (t * 10 + 7) % K t * 10 + 7 t * 10 t 10 7 K print(-1) print -1 main() main input = sys.stdin.readline sys.stdin.readline input def main():
    K = int(input())

    t = 7
    t %= K
    for i in range(K+1):
        if t == 0:
            print(i+1)
            break
        t = (t * 10 + 7) % K
    else:
        print(-1)
     def main():
    K = int(input())

    t = 7
    t %= K
    for i in range(K+1):
        if t == 0:
            print(i+1)
            break
        t = (t * 10 + 7) % K
    else:
        print(-1)
     main
import sys
input = sys.stdin.readline

def main():
    K = int(input())

    t = 7
    t %= K
    for i in range(K+1):
        if t == 0:
            print(i+1)
            break
        t = (t * 10 + 7) % K
    else:
        print(-1)
    

main()