# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)

import sys

def main(K):

    m = 0

    for i in range(1, 10**6):

        m = (m * 10 + 7) % K

        if m == 0:

            print(i)

            return

    print((-1))



if __name__ == '__main__':

    input = sys.stdin.readline

    K = int(eval(input()))

    main(K)

K = int(eval(input()))

mod = 0

for i in range(K):

    mod = (10 * mod + 7) % K

    if mod == 0:

        print((i + 1))

        exit()

print((-1))

# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys


def main(K):
    m = 0
    for i in range(1, 10**6):
        m = (m * 10 + 7) % K
        if m == 0:
            print(i)
            return
    print((-1))


if __name__ == "__main__":
    input = sys.stdin.readline
    K = int(eval(input()))
    main(K)

K = int(eval(input()))
mod = 0
for i in range(K):
    mod = (10 * mod + 7) % K
    if mod == 0:
        print((i + 1))
        exit()
print((-1))

-# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) -import sys - - -def main(K): -    m = 0 -    for i in range(1, 10**6): -        m = (m * 10 + 7) % K -        if m == 0: -            print(i) -            return -    print((-1)) - - -if __name__ == "__main__": -    input = sys.stdin.readline -    K = int(eval(input())) -    main(K) +K = int(eval(input())) +mod = 0 +for i in range(K): +    mod = (10 * mod + 7) % K +    if mod == 0: +        print((i + 1)) +        exit() +print((-1))