import sys

K = int(input())
a = []
i = 1

a.append(7 % K)
while i < K:
    a.append((a[i-1]*10+7) % K)
    i += 1

i = 0
while i < K:
    if(a[i]==0):
        print(i+1)
        exit(0)
    i += 1

print(-1) import sys sys K = int(input()) K int(input()) int input() input a = [] a [] i = 1 i 1 a.append(7 % K) a.append a append 7 % K 7 K while i < K:
    a.append((a[i-1]*10+7) % K)
    i += 1 i < K i K a.append((a[i-1]*10+7) % K) a.append a append (a[i-1]*10+7) % K a[i-1]*10+7 a[i-1]*10 a[i-1] a i-1 i 1 10 7 K i += 1 i 1 i = 0 i 0 while i < K:
    if(a[i]==0):
        print(i+1)
        exit(0)
    i += 1 i < K i K if(a[i]==0):
        print(i+1)
        exit(0)
     a[i]==0 a[i] a i 0 print(i+1) print i+1 i 1 exit(0) exit 0 i += 1 i 1 print(-1) print -1 i = 0 0 i i = 1 1 i a = [] [] a K = int(input()) int(input()) K i += 1 1 i i += 1 1 i
import sys

K = int(input())
a = []
i = 1

a.append(7 % K)
while i < K:
    a.append((a[i-1]*10+7) % K)
    i += 1

i = 0
while i < K:
    if(a[i]==0):
        print(i+1)
        exit(0)
    i += 1

print(-1)