CodeEff/ECCO huggingface dataset:
# Original solution
def main():
    k = int(input().strip())
    x = 7 % k
    ans = -1
    for n in range(1, k + 1):
        if x == 0:
            ans = n
            break
        x = (10 * x + 7) % k

    print(ans)
    return


if __name__ == "__main__":
    main()


# Optimized solution
def main():
    k = int(input().strip())
    if k % 2 == 0 or k % 5 == 0:
        print((-1))
        return
    x = 7 % k
    for n in range(1, k + 1):
        if x == 0:
            print(n)
            return
        x = (10 * x + 7) % k

    print((-1))
    return


if __name__ == "__main__":
    main()
# Original solution
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
k = ni()
a = 0
for i in range(10**6):
    a=(a+7*pow(10,i,k))%k
    if a== 0:
        print(i+1)
        break
else:
    print(-1)


# Optimized solution
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
k = ni()

if k%2==0 or k%5==0:
    print(-1)
    exit()
if k%7==0:
    L=9*k//7
else:
    L=9*k
tmp=1
for i in range(1,10**6):
    tmp = tmp*10 %L
    if tmp==1:
        print(i)
        break
else:
    print(-1)
# Original solution
K = int(eval(input()))

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

# Optimized solution
num=int(eval(input()))
a=7
flag=0
for i in range(num):
    if a%num==0:
        print((i+1))
        flag=1
        break
    a=(a*10+7)%num
if flag==0:
    print((-1))
# Original solution
# -*- coding: utf-8 -*-
# 標準入力を取得
K = int(eval(input()))

# 求解処理
ans = -1
remainder = 7 % K
for i in range(1, 9000000):
    if remainder == 0:
        ans = i
        break
    remainder = (10 * remainder + 7) % K

# 結果出力
print(ans)


# Optimized solution
# -*- coding: utf-8 -*-

def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    K = int(eval(input()))

    return K


def main(K: int) -> None:
    """
    メイン処理.

    Args:\n
        K (int): 整数（1 <= K <= 10^6）
    """
    # 求解処理
    ans = -1
    remainder = 7 % K
    for i in range(1, 9000000):
        if remainder == 0:
            ans = i
            break
        remainder = (10 * remainder + 7) % K

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    K = get_input()

    # メイン処理
    main(K)
# Original solution
K = int(eval(input()))

flg = [False]*K

tmp = 7 % K
cnt = 1
if tmp == 0:
    print(cnt)
    exit()
while True:
    tmp = (tmp*10+7)%K
    if flg[tmp]:
        print((-1))
        break
    else:
        cnt += 1
        if tmp == 0:
            print(cnt)
            break
        flg[tmp] = True


# Optimized solution
K = int(eval(input()))
t = 7
t %= K

for i in range(K+1):
    if t == 0:
        print((i+1))
        exit()
    t = (t*10+7)%K
print((-1))
# Original solution
k = int(eval(input()))
x = 0
ans = -1
if k % 2 == 1:
    for i in range(10**6):
        x = (x + 7 * pow(10, i, k)) % k
        if x == 0:
            ans = i + 1
            break
print(ans)

# Optimized solution
def abc174_c():
    k = int(eval(input()))
    ans = -1
    if k % 2 == 0 or k % 5 == 0:
        return ans
    f = 0
    for i in range(k+1):
        f = (f * 10 + 7) % k
        if f == 0:
            ans = i + 1
            break
    return ans

if __name__ == '__main__':
    print((abc174_c()))
# Original solution
k=int(eval(input()))
ama=[0]*(k)
now=7
if now%k==0:
  print((1))
  exit()
else:
  ama[now%k]+=1
for _ in range(2*k):
  now=(now*10+7)%k
  if now%k==0:
    print((_+2))
    exit()
  elif ama[now%k]==0:
    ama[now%k]+=1
  else:
    print((-1))
    exit()
    
    

# Optimized solution
k=int(eval(input()))
ama=[0]*(k)
now=7%k
ama[now]+=1
if now==0:
  print((1))
  exit()
for i in range(2,k+1):
  now=(10*now+7)%k
  if ama[now]!=0 and now>0:
    print((-1))
    exit()
  elif now==0:
    print(i)
    exit()
  else:
    ama[now]+=1
# Original solution
K = int(eval(input()))
n = 7
c = 0
while 1:
  m = n % K
  c += 1
  if m == 0:
    break
  tmp = m * 10 + 7
  if tmp == n:
    print((-1))
    exit()
  n = tmp
print(c)

# Optimized solution
K = int(eval(input()))
n = 7
c = 0
while c <= K:
  n %= K
  c += 1
  if n == 0:
    print(c)
    exit()
  n = n * 10 + 7
print((-1))
# Original solution
K = int(eval(input()))

if(K%2 == 0):
    print("-1")
    exit()

A = 7
ans = 1
while(A < K): #O(6)
    A = A*10 + 7
    ans += 1

while(True):
    #print(A)
    A = A % K #1
    if(ans > K):
        print("-1")
    if(A==0): #1
        print(ans)
        exit()
    A = A * 10 + 7 # 1
    ans += 1# 1


# Optimized solution
K = int(eval(input()))

if(K%2 == 0):
    print("-1")
    exit()

A = 7
ans = 1
while(A < K): #O(6)
    A = A*10 + 7
    ans += 1

while(True):
    #print(A)
    A = A % K #1
    if(ans > K):
        print("-1")
        exit()
    if(A==0): #1
        print(ans)
        exit()
    A = A * 10 + 7 # 1
    ans += 1# 1
# Original solution
K = int(eval(input()))

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

# Optimized solution
K = int(eval(input()))

mod = 7 % K
for i in range(K):
    if mod == 0:
        print((i+1))
        exit()

    mod = (10*mod + 7) % K

if mod == 0:
    print(K)
else:
    print((-1))
# Original solution
k = int(eval(input()))
count = 1
n = 0
if k % 2 == 0 or k % 5 == 0:
    print((-1))
else:
  while 1:
      n = (n * 10 + 7) % k  
      if n == 0:
        break 
      count += 1
  print(count)

# Optimized solution
def main(h):
  count = 1
  n = 0
  for i in range (k):
    n = (n * 10 + 7) % k  
    if n == 0: 
      print(count)
      return 0
    count += 1
  print((-1))
  
if __name__ == '__main__':
  k = int(eval(input()))
  main(k)
# Original solution
K = int(eval(input()))

powlis = [pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K

lis = [(7 *powlis[i])%K  for i in range(K) ]

try:
    print((lis.index(0) + 1))
except:
    print((-1))

# Optimized solution
K = int(eval(input()))

powlis = [7*pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K
powlis[0] %= K


try:
    print((powlis.index(0) + 1))
except:
    print((-1))
# Original solution
K = int(eval(input()))
hist = set()

INF = 10**8

w = 0
for i in range(INF):
  w += 7 * pow(10,i,K)
  w %= K
  if w == 0:
    print((i+1))
    break
  else:
    if w in hist:
      print((-1))
      break
    else:
      hist.add(w)
      
#print(hist)


# Optimized solution
K = int(eval(input()))
hist = set()

INF = 10**8

w = 0
pows = 1
for i in range(INF):
  w += 7 * pows
  pows = pows * 10 % K
  w %= K
  if w == 0:
    print((i+1))
    break
  else:
    if w in hist:
      print((-1))
      break
    else:
      hist.add(w)
      
#print(hist)
# Original solution
def main():
    K = int(eval(input()))
    first = 7 % K
    curr = first
    yet = True
    ans = 1
    while yet:
        if curr == 0:
            print(ans)
            return
        curr = (curr*10+7) % K
        if first == curr:
            yet = False
        ans += 1
    print((-1))


if __name__ == "__main__":
    main()


# Optimized solution
def main():
    K = int(eval(input()))
    curr = 7 % K
    for i in range(1, K+1):
        if curr == 0:
            print(i)
            return
        curr = (curr*10+7) % K
    else:
        print((-1))


if __name__ == "__main__":
    main()
# Original solution
import sys
input=sys.stdin.readline

def main():
    K = int(eval(input()))
    
    if K % 7:
        L = 9*K
    else:
        L = 9*K//7
    a = 1
    for i in range(1,L+1):
        a = (a * 10) % L
        if a == 1:
            return i
    return -1
ans =main()
print(ans)

# Optimized solution
import sys
input = sys.stdin.readline


def main():
    K = int(eval(input()))
    
    if K%2==0:
        print((-1))
        return
    
    if K % 7:
        L = 9*K
    else:
        L = 9*K//7
    a = 1
    for i in range(1,L+1):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print((-1))
main()
# Original solution
import sys
input = sys.stdin.readline


def main():
    K = int(eval(input()))
    
    if K%2==0:
        print((-1))
        return
    
    if K % 7:
        L = 9*K
    else:
        L = 9*K//7
    a = 1
    for i in range(1,L+1):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print((-1))
main()

# Optimized solution
#!python3.8
# -*- coding: utf-8 -*-
# abc174/abc174_c
import sys
 
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
 
def main():
    K = i2n()
    a = 0
    if K % 7:
        L = 9 * K
    else:
        L = 9 * K // 7
    a = 1
    for i in range(1, K + 10):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print('-1')
    return

main()
# Original solution
import sys

i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())

def main():
    K = i2n()
    
    if K%2==0:
        print((-1))
        return
    
    if K % 7:
        L = 9*K
    else:
        L = 9*K//7
    a = 1
    for i in range(1,L+1):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print((-1))
main()

# Optimized solution
import sys
input = sys.stdin.readline

def main():
    K = int(eval(input()))
    
    if K%2==0:
        print((-1))
        return
    
    if K % 7:
        L = 9*K
    else:
        L = 9*K//7
    a = 1
    for i in range(1,K+10):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print((-1))
main()
# Original solution
k = int(eval(input()))
rem = 7%k
alreadys = [False]*k
alreadys[rem] = True

ans = 1
while True:
    if rem == 0:
        print(ans)
        exit()
    ans += 1
    rem = (rem*10+7)%k
    if alreadys[rem]:
        print((-1))
        exit()
    alreadys[rem] = True

# Optimized solution
k = int(eval(input()))
rem = 7%k
for i in range(10**6+1):
    if rem == 0:
        print((i+1))
        break
    rem = (rem*10+7)%k
else:
    print((-1))
# Original solution
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math
import bisect

def readInt():
  return int(eval(input()))
def readInts():
  return list(map(int, input().split()))
def readChar():
  return eval(input())
def readChars():
  return input().split()


x = 0
k = readInt()
a = 7%k
ans = 0
for i in range(10**6+1):
  x = (x*10%k+a)%k
  ans += 1
  if x==0:
    print(ans)
    exit()

print((-1))

# Optimized solution
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(eval(input()))
def readInts():
	return list(map(int, input().split()))
def readChar():
	return eval(input())
def readChars():
	return input().split()

k = readInt()

n = 7
for i in range(10**6):
	if n%k==0:
		print((i+1))
		exit()
	else:
		n = (n*10+7)%k

print((-1))
# Original solution
import sys

K = int(eval(input()))

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

print((-1))

# Optimized solution
import sys

K = int(eval(input()))

seven = 7
seven %= K
for i in range(K+2):
    if seven == 0:
        print((i+1))
        sys.exit()
    seven = seven * 10 + 7
    seven %= K

print((-1))
# Original solution
k = int(eval(input()))
if k % 2 == 0:
	print((-1))
	exit()
i = 7
cnt = 1
while i % k != 0:
	if i % k != i:
		i = i % k
	i = i * 10 + 7
	cnt += 1
print(cnt)

# Optimized solution
k = int(eval(input()))
j = 7

for i in range(k):
	if j % k < 1:
		print((i + 1))
		exit()
	j = (j * 10 + 7) % k
print((-1))
# Original solution
import sys 
from collections import defaultdict
sys.setrecursionlimit(10**6)
MOD = 10**9+7 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
K = int(readline())
a = defaultdict(int)
cnt = 0
N = 7
while True:
    cnt += 1
    s = N % K
    if s == 0:
        print(cnt)
        sys.exit()
    if s in a:
        print((-1))
        sys.exit()
    a[s] = 1
    N += pow(10,cnt,K)*7 
    N %= K

# Optimized solution
# -*- coding: utf-8 -*-
import sys 
from collections import defaultdict
sys.setrecursionlimit(10**6)
MOD = 10**9+7 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
K = int(readline())
cnt = 0
N = 7
for i in range(K+1):
    if N % K == 0:
        print((i+1))
        sys.exit()
    N = (N*10+7) % K
print((-1))
# Original solution
K=int(eval(input()))

D=7
for i in range(10000000):
    if D%K==0:
        print((i+1))
        break
#    print(D)
    D=D*10+7
    D%=K
else:
    print((-1))


# Optimized solution
K=int(eval(input()))

D=7
for i in range(1000000):
    if D%K==0:
        print((i+1))
        break
#    print(D)
    D=D*10+7
    D%=K
else:
    print((-1))
# Original solution
if __name__ == '__main__':

	k = int(eval(input()))

	# mod K 問題

	s = set()
	x = 7 % k
	i = 1
	cnt = -1
	while x not in s:
		if x == 0:
			cnt = i
			break
		s.add(x)
		x = (10 * x + 7) % k
		i += 1

	print(cnt)
	

# Optimized solution
if __name__ == '__main__':

	k = int(eval(input()))
	x = 0
	for i in range(10**6):
		x = (10 * x + 7) % k
		if x == 0:
			print((i+1))
			exit()
	print((-1))
# Original solution
k = int(eval(input()))
temp = 7
juu = 7
for i in range(1, 10**7):
  temp = temp % k
  if temp == 0:
    print(i)
    break
  juu = juu * 10 % k
  temp += juu % k
else:
  print((-1))


# Optimized solution
k = int(eval(input()))
temp = 7
juu = 7
for i in range(1, 10**6):
  temp = temp % k
  if temp == 0:
    print(i)
    break
  juu = (juu * 10) % k
  temp += juu % k
else:
  print((-1))
# Original solution
# k = int(input())
K = eval(input())
k = int(K)
# if k%2 == 0:
#     print(-1)
#     exit()

# r7 = 7%k
r = 0
for i in range(1,k*10):
    r = (r*10 + 7)%k

    # print('r {} i {}'.format(r,i))
    if r == 0:
        print(i)
        exit()
    # print(n)
print((-1))


# Optimized solution
k = int(eval(input()))
r = 0
for i in range(1, k+1):
    r = (r*10 + 7)%k
    if r == 0:
        print(i)
        exit()
print((-1))
# Original solution
k = int(eval(input()))
r = 0
for i in range(1, k+1):
    r = (r*10 + 7)%k
    if r == 0:
        print(i)
        exit()
print((-1))


# Optimized solution
def f(k):
    r = 7%k
    for i in range(k):
        if r == 0: return i+1
        r = (r*10 + 7)%k
    return -1

print((f(int(eval(input())))))
# Original solution
def f(k):
    r = 7%k
    for i in range(k):
        if r == 0: return i+1
        r = (r*10 + 7)%k
    return -1

print((f(int(eval(input())))))


# Optimized solution
def f(k):
    r = 7%k
    for i in range(k):
        if not r: return i+1
        r = (r*10 + 7)%k
    return -1

print((f(int(eval(input())))))
# Original solution
# -*- coding: utf-8 -*-

def main():
    import sys

    K = int( sys.stdin.readline() )

    A = 7
    add_digit = 7
    i = 1
    checked = set()


    while True:
        if A % K == 0:
            print(i)
            return

        elif A in checked:
            print("-1")
            return
        
        checked.add(A)
        add_digit = (add_digit * 10) % K
        
        next_A = add_digit + A
        next_A %= K

        A = next_A
        i += 1


if __name__ == "__main__":
    main()


# Optimized solution
# -*- coding: utf-8 -*-
import sys


def main():
    K = int( sys.stdin.readline() )
 
    A = 7

    for i in range(K):
        if A % K == 0:
            print((i+1))
            return

        A = (A * 10) + 7
        A %= K
    
    print((-1))


if __name__ == "__main__":
    main()
# Original solution
K = int(eval(input()))
Judge = True
remain_initial = 7 % K
remain = 0
i = 0

while Judge == True:
    i += 1
    remain_str = str(remain) + '7'
    number = int(remain_str)
    remain = number % K

    if number % K == 0:
        Judge = False
        answer = i

    elif i == 1:
        continue

    elif number % K == remain_initial:
        Judge = False
        answer = -1

print(answer)

# Optimized solution
K = int(eval(input()))
remain = 0
i = 0

answer = -1

for i in range(1, K+5):
    number = remain*10 + 7

    remain = number % K

    if remain == 0:
        answer = i
        break

print(answer)
# Original solution
K = int(eval(input()))

n = 1
x = 7


if K % 2 == 0:
  print(( -1 ))
  exit( 0 )
#

while 1:
  if x % K == 0:
    print( n )
    break
  x = (x * 10 + 7) % K
  n += 1
  if x == 7:
    print(( -1 ))
    break
#


# Optimized solution
K = int(eval(input()))

n = 1
x = 7


if (K % 2 == 0)or(K % 5 == 0):
  print(( -1 ))
  exit( 0 )
#

while 1:
  if x % K == 0:
    print( n )
    break
  x = (x * 10 + 7) % K
  n += 1
#
# Original solution
k=int(eval(input()))

if k%2==0:
  print((-1)); exit()

cnt=num=0
while 1:
  num+=7*pow(10,cnt,k)
  num%=k
  cnt+=1
  if num==0:
    break
print(cnt)

# Optimized solution
k=int(eval(input()))

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

cnt=num=0
while 1:
  num+=7*pow(10,cnt,k)
  num%=k
  cnt+=1
  if num==0:
    break
print(cnt)
# Original solution
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    d = dict()
    k = ni()
    c = 7 % k
    x = d[c] = 1
    while True:
        c = (c * 10 + 7) % k
        if c in d:
            break
        x += 1
        d[c] = x
    print(d.get(0, -1))
    return

solve()


# Optimized solution
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    k = ni()
    c = 0
    for i in range(k):
        c = (c * 10 + 7) % k
        if c == 0:
            print(i+1)
            break
    else:
        print(-1)
    return

solve()
# Original solution
K = int(eval(input()))
x = 7 % K #mod(K)
if K == 1 or K == 7:
  print((1))
  exit()
ans = 1
i = 0
while i < K:
  ans += 1
  x = (x * 10 + 7) % K
  
  if x == 7 % K:
    print('-1')
    exit()
  if x == 0:
    print(ans)
    exit()
  i += 1
print('-1')

# Optimized solution
K = int(eval(input()))
x = 7 % K #mod(K)
if K == 1 or K == 7:
  print((1))
  exit()
ans = 1
i = 0
while i < K:
  ans += 1
  x = (x * 10 + 7) % K
  
  
  if x == 0:
    print(ans)
    exit()
  i += 1
print('-1')
# Original solution
K = int(eval(input()))
rest = 7%K
count=1
while (count<=K):
    if rest == 0:
        print(count)
        exit()
    count +=1
    rest = (rest%K*10%K + 7%K)%K
print((-1))


# Optimized solution
K = int(eval(input()))
rest = 7%K
count=1
while (count<=K):
    if rest == 0:
        print(count)
        exit()
    count +=1
    rest = (rest%K*10 + 7)%K
print((-1))
# Original solution
k = int(eval(input()))
if k % 2 == 0:
    print((-1))
    exit()
a = 7
ans = 1
while True:
    if a % k == 0:
        print(ans)
        exit()
    a = (a*10+7) % k
    ans += 1


# Optimized solution
k = int(eval(input()))
if k % 2 == 0 or k%5==0:
    print((-1))
    exit()
a = 7
ans = 1
while True:
    if a % k == 0:
        print(ans)
        exit()
    a = (a*10+7) % k
    ans += 1
# Original solution
K=int(eval(input()))
num=7
for i in range(1000000):
  modnum=num%K
  if modnum==0:
    print((i+1))
    exit()
  num=modnum*10+7
print((-1))

# Optimized solution
K=int(eval(input()))
a=7
for i in range(K+1):
  if a%K==0:
    print((i+1))
    exit()
  else:
    a=a*10+7
    a%=K
print((-1))
# Original solution
K=int(eval(input()))

if K%2==0:
    print((-1))
    exit(0)
    
ans=[0]*(pow(10,6)+1)
ans[0]=0

for i in range(1,pow(10,6)):
    ans[i]=(ans[i-1]*10+7)%K
    if ans[i]==0:
        print(i)
        exit(0)

print((-1))

# Optimized solution
import functools

K=int(eval(input()))
 
if K%2==0:
    print((-1))
    exit(0)

mod=0

for i in range(1,pow(10,6)):
    mod=(mod*10+7)%K
    if mod==0:
        print(i)
        exit(0)
        
print((-1))
# Original solution
k = int(eval(input()))

if k % 2 == 0 or k % 5 == 0:
    print((-1))
    exit()
ans = 1
a = 7 % k
while a:
    a = a*10 + 7
    a %= k
    ans += 1
print(ans)

# Optimized solution
k = int(eval(input()))

if k % 2 == 0 or k % 5 == 0:
    print((-1))
else:
    a = 7 % k
    cnt = 1
    while a:
        a = (a*10 + 7) % k
        cnt += 1
    print(cnt)
# Original solution
import sys

k = int(eval(input()))

a =7%k
if a == 0:
    print((1))
    sys.exit()

for i in range(2,10**7):
    a = (10*a+7) % k
    if a == 0:
        print(i)
        sys.exit()
    
print((-1))

# Optimized solution
import sys
def main():
    k = int(eval(input()))

    a =7%k
    if a == 0:
        print((1))
        sys.exit()

    for i in range(2,10**7):
        a = (10*a+7) % k
        if a == 0:
            print(i)
            sys.exit()

    print((-1))
    
main()
# Original solution
k = int(eval(input()))
if k%2 == 0:
    ans = -1
else:
    x = 0
    ans = -1
    for i in range(10**6+1):
        x += 7*pow(10, i, k)
        x %= k
        if x%k == 0:
            ans = i+1
            break
print(ans)

# Optimized solution
k = int(eval(input()))
x = 0
ans = -1
for i in range(10**6+1):
    x = 10*x + 7
    x %= k
    if x == 0:
        ans = i+1
        break
print(ans)
# Original solution
K = int(eval(input()))
firsta = 7 % K
seconda = 77 % K
if firsta == 0:
    print((1))
elif firsta == seconda:
    print((-1))
else:
    ans = 2
    preva = seconda
    while preva != firsta and preva != 0:
        preva = ((preva*10)+7) % K
        ans += 1
        if preva == firsta:
            ans = -1
    print(ans)

# Optimized solution
K = int(eval(input()))
def check(k):
    aaa = 0
    prev = 7%k
    for i in range(0,k):
        aaa+=1
        if prev == 0:
            return(aaa)
        prev = (prev*10+7)%k
    return(-1)
print((check(K)))
# Original solution
k = int(eval(input()))

m = 7%k
ans = 1
jud = True
p = 70%k
while m != 0:
    m = (m + p)%k
    ans += 1
    p = p*10%k
    if p == 0:
        jud = False
        break
if jud:
    print(ans)
else:
    print((-1))


# Optimized solution
k = int(eval(input()))

m = 0
for i in range(k):
    m = (m*10 + 7)%k
    if m == 0:
        ans = i + 1
        break

if m == 0:
    print(ans)
else:
    print((-1))
# Original solution
K = int(eval(input()))
if K % 2 == 0:
    print((-1))
    exit()

x = 7 % K
i = 1
while True:
    if x == 0:
        print(i)
        exit()
    y = (x * 10 + 7) % K
    if x == y:
        print((-1))
        exit()
    x = y
    i += 1


# Optimized solution
K = int(eval(input()))
if K % 2 == 0:
    print((-1))
    exit()

x = 7 % K
i = 1
while True:
    if x == 0:
        print(i)
        exit()
    x = (x * 10 + 7) % K
    i += 1
    if i > 10**6:
        print((-1))
        exit()
# Original solution

k = int(eval(input()))

if k % 2 == 0 or k % 5 == 0:
    print((-1))
else:
    n = 7
    cnt = 1
    for i in range(k):
        if n % k == 0:
            break
        cnt += 1
        n = (n * 10 + 7) % k
    print(cnt)


# Optimized solution
# -*- coding: utf-8 -*-
k = int(eval(input()))
ans = 0
n = 7

if k % 2 == 0 or k % 5 == 0:
    print((-1))
    exit(0)
c = 1
while True:
    if n % k == 0:
        break
    n = (n * 10 + 7) % k
    c += 1

print(c)