import sys

K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print("-1")
    sys.exit()

x = 1
for i in range(1, 1000000):
    if (x * 7) % K == 0:
        print(i)
        sys.exit()
    x = (x + pow(10,i,K))%K

print("-1")
sys.exit() import sys sys K = int(input()) K int(input()) int input() input if K % 2 == 0 or K % 5 == 0:
    print("-1")
    sys.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" sys.exit() sys.exit sys exit x = 1 x 1 for i in range(1, 1000000):
    if (x * 7) % K == 0:
        print(i)
        sys.exit()
    x = (x + pow(10,i,K))%K i range(1, 1000000) range 1 1000000 if (x * 7) % K == 0:
        print(i)
        sys.exit()
     (x * 7) % K == 0 (x * 7) % K x * 7 x 7 K 0 print(i) print i sys.exit() sys.exit sys exit x = (x + pow(10,i,K))%K x (x + pow(10,i,K))%K x + pow(10,i,K) x pow(10,i,K) pow 10 i K K print("-1") print "-1" sys.exit() sys.exit sys exit x = (x + pow(10,i,K))%K (x + pow(10,i,K))%K x K = int(input()) int(input()) K x = 1 1 x
import sys

K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print("-1")
    sys.exit()

x = 1
for i in range(1, 1000000):
    if (x * 7) % K == 0:
        print(i)
        sys.exit()
    x = (x + pow(10,i,K))%K

print("-1")
sys.exit()
