import sys

read = sys.stdin.read

readlines = sys.stdin.readlines

def main():

    k = int(eval(input()))

    if k % 2 == 0 or k % 5 == 0:

        print((-1))

        sys.exit()

    p = 7

    plus = 7

    amari = set()

    r = 1

    while (p % k) != 0:

        if p in amari:

            print((r, -1, p))

            sys.exit()

        else:

            amari.add(p)

            plus = (plus * 10) % k

            p += plus

            p = p % k

            r += 1

    print(r)



if __name__ == '__main__':

    main()
import sys

read = sys.stdin.read

readlines = sys.stdin.readlines

def main():

    k = int(eval(input()))

    if k % 2 == 0 or k % 5 == 0:

        print((-1))

        sys.exit()

    p = 7       # '7,77,777…'のmod kをいれる変数

    plus = 7    # '70,700,7000…'のmod kをいれる変数

    r = 1       # カウント

    while (p % k) != 0: # kで割り切れるかチェック

        plus = (plus * 10) % k   # pに足すもう1桁のmod kを計算。

        p += plus                # pにもう１桁を足す

        p = p % k                # pのmod kをとる

        r += 1

    print(r)



if __name__ == '__main__':

    main()

import sys

read = sys.stdin.read
readlines = sys.stdin.readlines


def main():
    k = int(eval(input()))
    if k % 2 == 0 or k % 5 == 0:
        print((-1))
        sys.exit()
    p = 7
    plus = 7
    amari = set()
    r = 1
    while (p % k) != 0:
        if p in amari:
            print((r, -1, p))
            sys.exit()
        else:
            amari.add(p)
            plus = (plus * 10) % k
            p += plus
            p = p % k
            r += 1
    print(r)


if __name__ == "__main__":
    main()

import sys

read = sys.stdin.read
readlines = sys.stdin.readlines


def main():
    k = int(eval(input()))
    if k % 2 == 0 or k % 5 == 0:
        print((-1))
        sys.exit()
    p = 7  # '7,77,777…'のmod kをいれる変数
    plus = 7  # '70,700,7000…'のmod kをいれる変数
    r = 1  # カウント
    while (p % k) != 0:  # kで割り切れるかチェック
        plus = (plus * 10) % k  # pに足すもう1桁のmod kを計算。
        p += plus  # pにもう１桁を足す
        p = p % k  # pのmod kをとる
        r += 1
    print(r)


if __name__ == "__main__":
    main()

-    p = 7 -    plus = 7 -    amari = set() -    r = 1 -    while (p % k) != 0: -        if p in amari: -            print((r, -1, p)) -            sys.exit() -        else: -            amari.add(p) -            plus = (plus * 10) % k -            p += plus -            p = p % k -            r += 1 +    p = 7  # '7,77,777…'のmod kをいれる変数 +    plus = 7  # '70,700,7000…'のmod kをいれる変数 +    r = 1  # カウント +    while (p % k) != 0:  # kで割り切れるかチェック +        plus = (plus * 10) % k  # pに足すもう1桁のmod kを計算。 +        p += plus  # pにもう１桁を足す +        p = p % k  # pのmod kをとる +        r += 1