import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def main():
    k = int(input())
    cur = 0

    for i in range(1, 10 ** 7):
        cur *= 10
        cur += 7
        cur %= k

        if cur == 0:
            print(i)
            return
    print(-1)


if __name__ == '__main__':
    main() import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 def input(): return sys.stdin.readline().rstrip() input def main():
    k = int(input())
    cur = 0

    for i in range(1, 10 ** 7):
        cur *= 10
        cur += 7
        cur %= k

        if cur == 0:
            print(i)
            return
    print(-1) main k = int(input()) k int(input()) int input() input cur = 0 cur 0 for i in range(1, 10 ** 7):
        cur *= 10
        cur += 7
        cur %= k

        if cur == 0:
            print(i)
            return
     i range(1, 10 ** 7) range 1 10 ** 7 10 7 cur *= 10 cur 10 cur += 7 cur 7 cur %= k cur k if cur == 0:
            print(i)
            return
     cur == 0 cur 0 print(i) print i return print(-1) print -1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def input(): return sys.stdin.readline().rstrip() def input(): return sys.stdin.readline().rstrip() input def main():
    k = int(input())
    cur = 0

    for i in range(1, 10 ** 7):
        cur *= 10
        cur += 7
        cur %= k

        if cur == 0:
            print(i)
            return
    print(-1) def main():
    k = int(input())
    cur = 0

    for i in range(1, 10 ** 7):
        cur *= 10
        cur += 7
        cur %= k

        if cur == 0:
            print(i)
            return
    print(-1) main
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def main():
    k = int(input())
    cur = 0

    for i in range(1, 10 ** 7):
        cur *= 10
        cur += 7
        cur %= k

        if cur == 0:
            print(i)
            return
    print(-1)


if __name__ == '__main__':
    main()