k = int(input())

if k == 1:
    print('1')
    exit()
if k % 2 == 0 or k % 5 == 0:
    print('-1')
    exit()

k *= 9
a = 10
for i in range(10*k):
    if (7 * (a - 1 + k)) % k == 0:
        print(str(i+1))
        exit()
    a = (a*10) % k k = int(input()) k int(input()) int input() input if k == 1:
    print('1')
    exit() k == 1 k 1 print('1') print '1' exit() exit if k % 2 == 0 or k % 5 == 0:
    print('-1')
    exit() k % 2 == 0 or k % 5 == 0 k % 2 == 0 k % 2 k 2 0 k % 5 == 0 k % 5 k 5 0 print('-1') print '-1' exit() exit k *= 9 k 9 a = 10 a 10 for i in range(10*k):
    if (7 * (a - 1 + k)) % k == 0:
        print(str(i+1))
        exit()
    a = (a*10) % k i range(10*k) range 10*k 10 k if (7 * (a - 1 + k)) % k == 0:
        print(str(i+1))
        exit()
     (7 * (a - 1 + k)) % k == 0 (7 * (a - 1 + k)) % k 7 * (a - 1 + k) 7 a - 1 + k a - 1 a 1 k k 0 print(str(i+1)) print str(i+1) str i+1 i 1 exit() exit a = (a*10) % k a (a*10) % k a*10 a 10 k k = int(input()) int(input()) k a = (a*10) % k (a*10) % k a k *= 9 9 k a = 10 10 a
k = int(input())

if k == 1:
    print('1')
    exit()
if k % 2 == 0 or k % 5 == 0:
    print('-1')
    exit()

k *= 9
a = 10
for i in range(10*k):
    if (7 * (a - 1 + k)) % k == 0:
        print(str(i+1))
        exit()
    a = (a*10) % k
