# -*- coding: utf-8 -*-



def main():

    import sys



    K = int( sys.stdin.readline() )



    A = 7

    add_digit = 7

    i = 1

    checked = set()





    while True:

        if A % K == 0:

            print(i)

            return



        elif A in checked:

            print("-1")

            return

        

        checked.add(A)

        add_digit = (add_digit * 10) % K

        

        next_A = add_digit + A

        next_A %= K



        A = next_A

        i += 1





if __name__ == "__main__":

    main()

# -*- coding: utf-8 -*-

import sys





def main():

    K = int( sys.stdin.readline() )

 

    A = 7



    for i in range(K):

        if A % K == 0:

            print((i+1))

            return



        A = (A * 10) + 7

        A %= K

    

    print((-1))





if __name__ == "__main__":

    main()

# -*- coding: utf-8 -*-
def main():
    import sys

    K = int(sys.stdin.readline())
    A = 7
    add_digit = 7
    i = 1
    checked = set()
    while True:
        if A % K == 0:
            print(i)
            return
        elif A in checked:
            print("-1")
            return
        checked.add(A)
        add_digit = (add_digit * 10) % K
        next_A = add_digit + A
        next_A %= K
        A = next_A
        i += 1


if __name__ == "__main__":
    main()

# -*- coding: utf-8 -*-
import sys


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


if __name__ == "__main__":
    main()

+import sys + + -    import sys - -    add_digit = 7 -    i = 1 -    checked = set() -    while True: +    for i in range(K): -            print(i) +            print((i + 1)) -        elif A in checked: -            print("-1") -            return -        checked.add(A) -        add_digit = (add_digit * 10) % K -        next_A = add_digit + A -        next_A %= K -        A = next_A -        i += 1 +        A = (A * 10) + 7 +        A %= K +    print((-1))