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

    rem = set()
    n = ans = 0

    while True:
        n = n * 10 + 7
        ans += 1

        if n % K == 0:
            print(ans)
            break
        else:
            n = n % K
            
            if n in rem:
                print(-1)
                break
            else:
                rem.add(n)
                
if __name__ == "__main__":
    main2() def main2():
    K = int(input())

    rem = set()
    n = ans = 0

    while True:
        n = n * 10 + 7
        ans += 1

        if n % K == 0:
            print(ans)
            break
        else:
            n = n % K
            
            if n in rem:
                print(-1)
                break
            else:
                rem.add(n)
                 main2 K = int(input()) K int(input()) int input() input rem = set() rem set() set n = ans = 0 n 0 = ans = 0 ans 0 while True:
        n = n * 10 + 7
        ans += 1

        if n % K == 0:
            print(ans)
            break
        else:
            n = n % K
            
            if n in rem:
                print(-1)
                break
            else:
                rem.add(n)
                 True n = n * 10 + 7 n n * 10 + 7 n * 10 n 10 7 ans += 1 ans 1 if n % K == 0:
            print(ans)
            break
        else:
            n = n % K
            
            if n in rem:
                print(-1)
                break
            else:
                rem.add(n)
                 n % K == 0 n % K n K 0 print(ans) print ans break n = n % K n n % K n K if n in rem:
                print(-1)
                break
            else:
                rem.add(n)
                 n in rem n rem print(-1) print -1 break rem.add(n) rem.add rem add n if __name__ == "__main__":
    main2() __name__ == "__main__" __name__ "__main__" main2() main2 def main2():
    K = int(input())

    rem = set()
    n = ans = 0

    while True:
        n = n * 10 + 7
        ans += 1

        if n % K == 0:
            print(ans)
            break
        else:
            n = n % K
            
            if n in rem:
                print(-1)
                break
            else:
                rem.add(n)
                 def main2():
    K = int(input())

    rem = set()
    n = ans = 0

    while True:
        n = n * 10 + 7
        ans += 1

        if n % K == 0:
            print(ans)
            break
        else:
            n = n % K
            
            if n in rem:
                print(-1)
                break
            else:
                rem.add(n)
                 main2
def main2():
    K = int(input())

    rem = set()
    n = ans = 0

    while True:
        n = n * 10 + 7
        ans += 1

        if n % K == 0:
            print(ans)
            break
        else:
            n = n % K
            
            if n in rem:
                print(-1)
                break
            else:
                rem.add(n)
                
if __name__ == "__main__":
    main2()