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

A = 0
for i in range(K):
    A = (10 * A + 7) % K
    if A == 0:
        print(i+1)
        break import sys sys K = int(input()) K int(input()) int input() input if K%5==0 or K%2==0:
    print("-1")
    sys.exit() K%5==0 or K%2==0 K%5==0 K%5 K 5 0 K%2==0 K%2 K 2 0 print("-1") print "-1" sys.exit() sys.exit sys exit A = 0 A 0 for i in range(K):
    A = (10 * A + 7) % K
    if A == 0:
        print(i+1)
        break i range(K) range K A = (10 * A + 7) % K A (10 * A + 7) % K 10 * A + 7 10 * A 10 A 7 K if A == 0:
        print(i+1)
        break A == 0 A 0 print(i+1) print i+1 i 1 break A = 0 0 A K = int(input()) int(input()) K A = (10 * A + 7) % K (10 * A + 7) % K A
import sys 
K = int(input())
if K%5==0 or K%2==0:
    print("-1")
    sys.exit()

A = 0
for i in range(K):
    A = (10 * A + 7) % K
    if A == 0:
        print(i+1)
        break