peterverebics/CodeNet_Python_118 huggingface dataset:
# https://atcoder.jp/contests/abc174/submissions/15768313 さんの回答、参照

K = int(input())
num = 0
if K%2 == 0:
    print(-1)
else:
    for i in range(1, 1000000):
        num = num*10 + 7
        num %= K
        if num == 0:
            print(i)
            break
    else:
        print(-1)
import time
start=time.time()
k=int(input())
if k%2==0:exit(print(-1))
ans=0
x=k
for i in range(10**9):
  while x%10!=7:
    x+=k
    if time.time()-start>=1.9:exit(print(-1))
  x//=10
  if x==0:exit(print(i+1))
K = int(input())

ans = -1
tmp = 0
for i in range(1, K + 1):
    tmp = (tmp*10%K + 7) % K
    if tmp == 0:
        ans = i
        break

print(ans)
def main():
    K = int(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()
k = int(input())
if k%2 == 0 or k%5 == 0:
    print(-1)
    exit()
mod = 7 % k
ans = 1
while mod != 0:
    mod = (mod*10+7)%k
    ans += 1
print(ans)
k=int(input())
s=0
for i in range(1,10**6):
  s=(s*10+7)%k
  if s==0:
    print(i)
    break
else:
  print(-1)
#import
#import math
#import numpy as np
K = int(input())

if K == 7:
    print(1)
    exit()

t = 7 % K
    
for i in range(1, K * 2):
    if t == 0:
        print(i)
        exit()

    t = (t * 10 + 7) % K

print(-1)
from sys import stdin
K = int(stdin.readline().rstrip())
def main(K):
  a=0
  for i in range(1,K+1):
    a = ((10%K) * a + 7)%K
    if a == 0:
      return i
  return -1
print(main(K))
k = int(input())
mod = 7 % k
counter = 1
memo = 1
mod_map = set()
mod_map.add(mod)
while mod != 0:
    memo = ((memo % k) * (10 % k)) % k
    mod = (mod + 7 * memo) % k
    if mod not in mod_map:
        mod_map.add(mod)
    else:
        counter = -1
        break
    counter += 1
    if mod == 0:
        break
print(counter)
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    x = -1
else:
    x = 1
    y = 7
    z = 7
    while y % k != 0:
        z = (z * 10) % k
        y += z
        x += 1
print(x)
from collections import defaultdict

k = int(input())

ms = defaultdict(int)

ans = 1
i = 7
while True:
    if i % k == 0:
        print(ans)
        exit()
    i = (i * 10 + 7) % k
    if ms[i] > 0:
        print(-1)
        exit()
    ms[i] += 1
    ans += 1
k=int(input())
curr=7
curr=curr%k
count=1
if(k%2==0 or k%5==0):
	print(-1)
else:
	for i in range(1,k+1):
		if(curr==0):
			print(count)
			break
		else:
			curr=(curr*10+7)%k
			count+=1
#C
import sys
k=int(input())
s=0

for i in range(k):
    s=s*10+7
    if s%k!=0:
        s=s%k
    else:
        print(i+1)
        sys.exit()
print(-1)
K = int(input())
l = [0 for i in range(K)]
r = 0
for i in range(K):
    r = (10*r+7)%K
    if r == 0:
        print(i+1)
        break
    elif l[r] != 0:
        print(-1)
        break
    else:
        l[r] = 1
limit = pow(10, 7)
K = int(input())
num = "7"
if K % 2 == 0 or K % 5 == 0:
    print (-1)
else:
    total = 0
    flag = False
    for i in range(1, limit + 1):
        total = (total * 10 + 7) % K
        if total == 0:
            flag = True
            break
    if flag:
        print (i)
    else:
        print(-1)
import sys
def Ii():return int(sys.stdin.readline())
def Mi():return map(int,sys.stdin.readline().split())
def Li():return list(map(int,sys.stdin.readline().split()))

k = Ii()
if k%2 == 0 or k%5 == 0:
  print(-1)
  exit(0)
elif k%7 == 0:
  k = k//7
ans = 1
a = 10
mod = a%(9*k)
while mod != 1:
  mod *= 10
  mod = mod%(9*k)
  ans += 1
  
print(ans)
K = int(input())

cur = 7
for i in range(1, K + 1):
    if cur % K == 0:
        print(i)
        quit()
    cur = (10 * cur + 7) % K

print(-1)
k = int(input())

mod = 7%k
path = [mod]
ans = '-1'

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    path.append(mod)
    if mod == path[0]:
        ans = '-1'
        break

print(ans)
K = int(input())

def f(K):
    v = 0
    for i in range(1, K + 1):
        v = (v * 10 + 7) % K
        if v == 0:
            return i
    return -1

print(f(K))
k = int(input())
ans = 1
x = 7
while ans <= k:
    if x % k == 0:
        print(ans)
        break
    x = x * 10 + 7
    x %= k
    ans += 1
else:
    print(-1)
k = int(input())

ans = -1
memo = 7 % k
a = 7 % k
for i in range(k):
    if a == 0:
        ans = i+1
        break
    a = (10*a+7) % k
print(ans)
#! /usr/bin/env python3

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

k = int(readline())

ans = -1
acc = 7 % k
for n in range(1, k + 10):
    if acc == 0:
        ans = n
        break
    acc = (10 * acc + 7) % k

print(ans)
K=int(input())
res=1
x=0
for i in range(K):
    x+=7*res
    x%=K
    if x%K==0:
        print(i+1)
        break
    res*=10
    res%=K
else:
    print(-1)
K = int(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')
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()
curr = 0
i = 1
while True:
  curr *= 10
  curr += 7
  curr %= k
  if curr == 0:
    print(i)
    break
  i += 1
  if i > 1000000:
      print(-1)
      break
k = int(input())
if k % 2 == 0:
    print(-1)
elif k in [1,7]:
  	print(1)
else:
  amari = [7]
  tmp = 7
  for i in range(k):
      tmp = (tmp * 10) % k
      if tmp != 7:
          amari.append(tmp%k)
      else:
          break
  amari = amari * ((k//len(amari)) +1)

  ans = amari[0]
  for i in range(1, k+1):
      ans += amari[i]
      if ans % k == 0:
          print(i+1)
          break
  else:
    print(-1)
k = int(input())
dp =[0]
for i in range(10**6+1):
    dp.append((dp[-1]*10+7)%k)
    if dp[-1]==0:print(i+1);exit()
print(-1)
import sys

k = int(input())
n = 7
for i in range(k):
  if (n % k == 0):
    print(i + 1)
    sys.exit()
  n = (n * 10 + 7) % k

print(-1)
k=int(input())

ans=7
cnt=1
if k%2==0 or k%5==0:
    print(-1)
else:
    while True:
        if ans%k==0:
            break
        ans=(ans*10+7)%k
        cnt+=1
    print(cnt)
K = int(input())



seed = 0
OK = False
for i in range(K):
    seed = (10*seed +7)%K
    if seed == 0:
        print(i+1)
        OK = True
        break
if not OK:
    print(-1)
import sys
def main():
    k = int(input())
    
    if k == 7 or k == 1:
        print(1)
        sys.exit()
    
    r = 7%k
    g = {r}
    ans = 1
    while True:
        ans+=1
        r = (10*r+7)%k
        if r==0:
            print(ans)
            break
        if r in g:
            print(-1)
            break
        else:
            g.add(r)
main()
K=int(input())

if K%7==0:
    L=9*K//7
else:
    L=9*K

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

mod=1
ans=0
for i in range(L):
    mod*=10
    mod=mod%L
    if mod==1:
        ans=i+1
        break

print(ans)
import sys
input = sys.stdin.readline

k = int(input())

n = 1

if k % 2  == 0:
    n = -1
else:
    r = 7 % k
    s = r

    while True:
        if r == 0:
            break
        elif n > 1000000:
            n = -1
            break
        else:
            r = (r * 10 + s) % k
            n += 1


print(n)
import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
import heapq
#import math
import itertools
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))

k = ri()
reses=[]
cnt = 1
tmp = 7
for i in range(k+1):
    res = tmp % k
    if res==0:
        print(cnt)
        sys.exit(0)
    tmp = res * 10 + 7
    cnt += 1
print(-1)
import sys
input = lambda: sys.stdin.readline().rstrip('\r\n')

K = int(input())
i = 1
v = 7 % K
V = {v}
while v != 0:
	i += 1
	v = (10 * v + 7) % K
	if v in V:
		print(-1)
		break
	V.add(v)
else:
	print(i)
def resolve():
    K = int(input())
    a = [0] * (K + 1)
    a[1] = 7 % K
    for i in range(2, K + 1):
        a[i] = (a[i - 1] * 10 + 7) % K
    for i in range(1, K + 1):
        if a[i] == 0:
            print(i)
            return
    print(-1)


resolve()
k = int(input())
ku = k
a = [0]*ku
c = [0]*ku
b = [0]*ku

for i in range(ku):
    if i == 0:
        b[i] = 7%k
    else:
        b[i] = (b[i-1]*10+7)%k

if 0 in b:
    print(b.index(0)+1)
else:
    print(-1)
import sys

k = int(input())

a = 0

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

print(-1)
k = int(input())
x = 7
ans = 1
s = set()
while x%k != 0:
    ans += 1
    x = (x*10%k+7)%k
    if x in s:
        ans = -1
        break
    s.add(x)
print(ans)
k = int(input())

num = 0
res = 0
cnt = [0] * k
while True:
    num = (num * 10 % k + 7) % k
    res += 1

    if num == 0:
        print(res)
        break

    if cnt[num] == 1:
        print(-1)
        break

    cnt[num] += 1
k = int(input())
a = [7] * (10 ** 7)
if k == 2:
    print(-1)
    exit()
for i in range(10 ** 7-1):
    a[i] %= k
    if a[i] == 0:
        print(i + 1)
        exit()
    a[i + 1] = a[i] * 10+7
print(-1)
K = int(input())
x = 0
for i in range(K + 5):
    x = (x * 10 + 7) % K
    if x == 0:
        print(i + 1)
        exit()
print(-1)
K = int(input())
if K%2==0:
    print(-1)
elif K==1:
    print(1)
elif K==7:
    print(1)
else:
    if K%7==0:
        K = K//7
    a = 1
    cnt = 1
    ind = -1
    for i in range(K):
        a = (a*10)%K
        cnt += a
        if cnt%K==0:
            ind = i
            break
    if ind<0:
        print(-1)
    else:
        print(ind+2)
def main():
    K = int( input())
    now = 7
    now %= K
    for i in range(10**7):
        if now == 0:
            print(i+1)
            return
        now = (now*10+7)%K
    print("-1")
if __name__ == '__main__':
    main()
k = int(input())
x = 7 % k
s = set()
i = 1

while (not x in s):
    if x == 0:
        print(i)
        exit()
    s.add(x)
    x = (x*10+7) % k
    i += 1
print(-1)
K = int(input())

t = 7 % K
if t == 0:
    print(1)
    exit()

for i in range(2, 10**6):
    t = (t * 10 + 7) % K
    if t == 0:
        print(i)
        exit()

print(-1)
ans=1
k=int(input())
t=7
for i in range(1,k+1):
  if t%k==0:
    print(i)
    exit()
  else:
    t=(t*10+7)%k
print(-1)
k = int(input())
n = 0
for i in range(k):
    n = (n * 10) + 7 
    n = n % k
    if n == 0:
        print(i + 1)
        exit()
print(-1)
k=int(input())

x=7
if k%2==0 or k%5==0:
    print(-1)
    exit()
for i in range(k):
    y=x%k
    
    if y==0:
        print(i+1)
        exit()
    x=10*y+7
import sys


def resolve(in_):
    k = int(next(in_))
    if not k % 2:
        return -1

    seven = 7 % k

    for i in range(1, 1000000):
        if not seven:
            return i
        i += 1
        seven = seven * 10 + 7
        if seven >= k:
            seven %= k

    return -1

def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()
k=int(input())
a=7
for i in range(k):
    if a%k==0:
        print(i+1)
        exit()
    a=(a*10+7)%k
print(-1)
import sys
from collections import defaultdict
K = int(input())

cnt = 0
now = 0
if K % 2==0:
    print(-1)
    sys.exit(0)

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

print(-1)
K = int(input())
 
x = 7
for i in range(K):
  if x % K == 0:
    print(i+1)
    exit()
  else:
    x = (10*x + 7) % K
print(-1)
K=int(input())
x=0
if K%2==0 or K%5==0:
    print(-1)
    exit()
for i in range(1000001):
    x=(x*10+7)%K
    if x==0:
        print(i+1)
        exit()
print(-1)
k=int(input())
sevens=0
for i in range(1,k+1):
  sevens=(sevens*10+7)%k
  if sevens==0:
    print(i)
    exit()
print(-1)
k, R, a = int(input()), 7, -1
for i in range(1, k+10):
    if not R%k:
        a = i
        break
    R = (R * 10 + 7) % k
print(a)
k = int(input())
x = 7 % k
ans = 1
for i in range(k):
    if x == 0:
        print(ans)
        exit()
    ans += 1
    x = (x * 10 + 7) % k

print(-1)
K = int(input())

count = 1
num = 7
if K % 2 == 0 or K % 5 == 0:
    count = -1
else:
    while True:
        if num % K == 0:
            break
        num = (num*10 + 7) % K
        count += 1
        if count >= 10**6 * 10**5:
            count = -1
            break
print(count)
k = int(input())
c = 0
x = 7
found = False
while c <= k:
    if x % k == 0:
        found = True
        break
    c += 1
    x = ((x * 10) + 7) % k

if not found:
    print(-1)
else:
    print(c + 1)
def solve():
  K = int(input())
  if K%2==0 or K%5==0:
    return -1
  ans = 1
  cnt = 7%K
  i = 1
  while cnt!=0:
    cnt += 7*pow(10,i,K)
    cnt %= K
    i += 1
    ans += 1
  return ans
print(solve())
K = int(input())

A = [0 for _ in range(K)]
for i in range(K):
    if i == 0:
        mod = 7 % K
    else:
        mod = (10 * A[i-1] + 7) % K
    A[i] = mod
    if mod == 0:
        print(i+1)
        exit()
print(-1)
k = int(input())

if(k%2 == 0 or k%5 == 0):
    print('-1')
else:
    if(k%7 == 0):
        k = k // 7
    num = 1
    ans = 1
    while(True):
        if(num%k == 0):
            print(ans)
            break
        else:
            num %= k
            num *= 10
            num += 1
            ans += 1
K = int(input())

if K%7 == 0:
  L = 9*K/7
else:
  L = 9*K
s = 1

for i in range(1, 9*(10**6)+1):
  s = s*10%L
  if s == 1:
    print(i)
    exit()

print("-1")
K = int(input())
x = 7 % K
num_list = []

for count in range(1, K + 1):
  if x == 0:
    print(count)
    break
  x = (x * 10 + 7) % K

else: print(-1)
K = int(input())
n = 7%K
r = 1
for i in range(10**6+5):
    if n==0:
        print(i+1)
        exit()
    r *= 10
    n += r*7
    r %= K
    n %= K
print(-1)
K = int(input())

cnt=1
Num=7%K
while cnt<=K:
  if K%2==0:
    print('-1')
    break
  if Num%K==0:
    print(cnt)
    break
  else:
    Num = (10*Num + 7)%K
    cnt+=1
else:
  print('-1')
K = int(input())
a = [7 % K]
for i in range(1, K+1):
    a.append((a[i-1]*10 + 7) % K)
flag = True
for i in range(len(a)):
    if a[i] == 0:
        print(i+1)
        flag = False
        break
if flag:
    print(-1)
K = int(input())

n = 7
ans = -1
i = 1
if K%2==0:
    ans = -1
else:
    for i in range(K*2+10):
        if n%K==0:
            ans = i+1
            break
        n *= 10
        n += 7
        n %= K
print(ans)
K = int(input())
ans = -1
keep = 0
check = 7
for i in range(K):
    keep = (keep + check) % K
    if keep == 0:
        ans = i + 1
        break
    check = (check * 10) % K
print(ans)
K = int(input())
seven = 7
MOD7 = 7 % K
MOD70 = 70 % K
MOD77 = MOD7 + MOD70
if K % 2 == 0:
    print(-1)
elif MOD7 == 0:
    print(1)
else:
    for i in range(1,10**6):
        if MOD77 % K == 0:
            break
        MOD70 = (MOD70 * 10) % K
        MOD77 += MOD70
        MOD77 = MOD77 % K
    if i >= 10**6 - 1:
        print(-1)
    else:
        print(i+1)
def solve():
    n = int(input())
    lim = 100000000
    s = 0
    for i in range(lim):
        s *= 10
        s += 7
        s %= n
        if s == 0:
            print(i + 1)
            exit()
    print(-1)

solve()
k = int(input())
if k % 2 == 0:
    print(-1)
    exit()

ten = 1
now = 0
for i in range(10**8):
    x = (ten*7)%k
    now = (now+x)%k
    if now == 0:
        print(i+1)
        exit()
    ten = ten*10%k
print(-1)
K=int(input())

if K%7==0:
    L=9*K//7
else:
    L=9*K

mod=1
ans=-1
for i in range(1,L+1):
    mod=(mod*10)%L
    if mod%L==1:
        ans=i
        break

print(ans)
k=int(input())
s=7
i=1
while s%k!=0:
  i+=1
  s=10*(s%k)+7
  if i==k+1:
    break
else:
  print(i)
  exit()
print(-1)
k = int(input())
num = 7
for i in range(k + 2):
    if num % k == 0:
        print(i + 1)
        exit()
    else : 
        num = ( num * 10 + 7 ) % k
print(-1)
K = int(input())
a = 7
flag = True

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

if flag:
    print(-1)
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
else:
  t=7
  ans=1
  while True:
    if t%k==0:
      print(ans)
      break
    t=(t*10+7)%k
    ans=ans+1
K = int(input())

count = -1
n = 7
for i in range(K):
    if n % K == 0:
        count = i+1
        break
    n = int(str(n)+'7')
    n %= K
print(count)
K=int(input())
ans=[0]*K
rem=7
for i in range(K):
    rem=rem%K
    if rem == 0:
        print(i+1)
        exit()
    else :
        if ans[rem]==1:
            print(-1)
            exit()
        else:ans[rem]=1
        rem=10*rem+7
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
if even(n):
    print(-1)
    exit()
elif n%5==0:
    print(-1)
    exit()
s = "7"
count = 1
while True:
    if int(s) < n:
        s = s+"7"
        count += 1
        continue
    else:
        res = int(s)%n
        if res == 0:
            print(count)
            exit()
        s = str(int(s)%n)
def main():

    K = int(input())
    if 7 % K == 0: return 1
    r = 7 % K
    for i in range(2, 1000000):
        r = (r * 10 + 7) % K
        if r == 0:
            return i
    return -1




if __name__ == '__main__':
    print(main())
K = int(input())
a = 7
 
for n in range(1,1+K):
  if a%K==0:
    print(n)
    exit()
  a = (a*10+7)%K
 
print(-1)
def solve():
	n = int(input())
	if n%2 == 0 or n%5 == 0:
		return -1
	if n % 7 == 0:
		n//=7
	n*=9
	cnt = 1
	cur = 10
	while cur % n != 1:
		cur = (cur * 10)%n
		cnt+=1
	return cnt




print(solve())
import sys
k=int(input())
n=7
if k%2==0:
    print(-1)
    sys.exit()
for i in range(1,k+1):
    if n%k==0:
        print(i)
        sys.exit()
    else:
        n=(10*(n%k)+7)%k
print(-1)
k=int(input())
if k&1==0 or k%5==0:
  print(-1)
  exit()
elif 7%k==0:
  print(1)
  exit()
m=7
a=b=1
while(m>0):
  a=a*10%k
  m=(m+7*a)%k
  b+=1
print(b)
K = int(input())

now = 7
r = 0
for d in range(1, K + 100):
    r = (r * 10 % K + 7) % K
    if r == 0:
        print(d)
        break
else:
    print(-1)
K = int(input())

if K == 1 or K == 7:
    print(1)
    exit()

v = 7
M = set([])
for i in range(1, K + 1):
    v = (v * 10 + 7) % K
    if v == 0:
        print(i + 1)
        exit()
    if v not in M:
        M.add(v)
    else:
        print(-1)
        exit()
k = int(input())

val = 7
cnt = 1

while cnt <= 10 ** 6:
  val %= k
  if val % k == 0:
    print(cnt)
    exit()
  cnt += 1
  val = val * 10 + 7

print(-1)
K = int(input())

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


now, cnt = 7, 1
while now % K != 0:
    cnt += 1
    now = now * 10 % K + 7

print(cnt)
from collections import defaultdict

K=int(input())

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

memo=defaultdict(int)
tmp=0
ans=0
while True:    
    tmp=(tmp*10+7)%K
    ans+=1
    if tmp==0:
        print(ans)
        break
    elif memo[tmp]==1:
        print(-1)
        break
    else:
        memo[tmp]+=1
k=int(input())
import sys
if k%2==0 or k%5==0:
  print(-1)
  sys.exit()

a=7
ans=1
while(1):
  if a%k==0:
    print(ans)
    sys.exit()
  else:
    a=a%k
    a=a*10+7
    ans=ans+1
K = int(input())
a = 7
for i in range(K):
    if a % K == 0:
        print(i+1)
        exit()
    a = (10 * a + 7) % K
print(-1)
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
else:
    ans = 1
    num = 7 % k
    temp = 7 % k
    while True:
        if num % k == 0:
            print(ans)
            break
        else:
            ans += 1
            temp = temp * 10 % k
            num += temp % k
            num %= k
k = int(input())

x = 7 % k
s = set()
for i in range(k):
    if x % k == 0:
        ans = i + 1
        break
    if x in s:
        ans = -1
        break

    s.add(x)
    x = 10 * x + 7
    x %= k

print(ans)
K = int(input())
if K%2 == 0:
  print(-1)
  exit()
num = 0
for i in range(10**6+1):
  num *= 10
  num += 7
  if num%K == 0:
    print(i+1)
    exit()
  num %= K
print(-1)
k = int(input())
ans = -1
x = 7 % k
for n in range(1, k + 10):
    if x == 0:
        ans = n
        break
    x = (10 * x + 7) % k
print(ans)
K = int(input())

if K % 7 == 0:
    L = 9 * K // 7
else:
    L = 9 * K

ans = 10
kou = -1
for i in range(1, 10**6):
    ans %= L
    if ans == 1:
        kou = i
        break
    else:
        ans *= 10

print(kou)
#!/usr/bin/env python3
import sys
from itertools import chain

# form bisect import bisect_left, bisect_right, insort_left, insort_right
# import numpy as np

# 7.n = 7 * 1.n = 101
7777


def solve(K: int):
    n = 7
    for answer in range(1, K + 1):
        if n % K == 0:
            return answer
        n = 10 * (n % K) + 7
    return -1


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # K = map(int, line.split())
    K = int(next(tokens))  # type: int
    answer = solve(K)
    print(answer)


if __name__ == "__main__":
    main()
import sys
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    sys.exit()
else:
    if k%7==0:
        l=(k//7)*9
    else:
        l=9*k
        
    j = 1
    n = 10
    rem = n%l
    while True:
        if rem == 1:
            print(j)
            sys.exit()
        rem = (rem*10)%l
        j+=1
'''
Created on 2020/08/22

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  K=int(pin())
  a=7%K
  for i in range(K):
    if a%K==0:
      print(i+1)
      break
    a=(10*a+7)%K
  else:
    print(-1)
  return 
main()

#解説AC
K = int(input())
if K % 2 == 0:
    print(-1)
else:
    r = 0
    rem = 7
    while (True):
        r += 1
        rem = rem % K
        if rem == 0:
            break
        if r > K:
            r = -1
            break
        rem = (rem * 10) + 7
    print(r)
# -*- coding:utf-8 -*-

def solve():
    K = int(input())
    a = 7%K
    i = 1
    Kset = set()
    Kset.add(a)
    while a!=0:
        a = (a*10+7)%K
        i += 1
        if a in Kset:
            print(-1)
            return
        Kset.add(a)
    print(i)


if __name__ == "__main__":
    solve()
import sys
import numpy as np
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    np.set_printoptions(threshold=20)
    K = int(input())
    if K % 2 == 0 or K % 5 == 0:
        print(-1)
        return
    cnt = 0
    now = 7
    while True:
        cnt += 1
        if now % K == 0:
            print(cnt)
            return
        now = now * 10 + 7
        now %= K


if __name__ == '__main__':
    main()
import sys
input = sys.stdin.readline

K=int(input())
if K%2==0 or K%5==0:
    print(-1)
else:   

    NOW=0

    for i in range(1,10**6+3):
        NOW=NOW+7*pow(10,i,K)
        NOW%=K

        if NOW==0:
            print(i)
            break
    else:
        print(-1)
def resolve():
    k = int(input())
    ans = 1
    ct = 0
    num = 7
    while ct <= 2*10**6:
        num %= k
        if num == 0:
            print(ans)
            exit()
        else:
            num = (num * 10 + 7)%k
            ans += 1
            ct += 1
    print(-1)
resolve()
k=int(input())
if k%7==0:
    k//=7
ans=0
if k%2==0 or k%5==0:
    ans=-1
else:
    cnt=1
    x=1
    while x%k!=0:
        cnt+=1
        x%=k
        x*=10
        x+=1
    ans=cnt
print(ans)
from collections import defaultdict

def main():
    k = int(input())
    dic = defaultdict(bool)
    sev = 7
    i = 1
    while(True):
        sev = sev%k
        if sev == 0:
            print(i)
            return
        if(dic[sev]):
            print(-1)
            return
        dic[sev] = True
        sev = (sev + 7*pow(10,i,k))%k
        i += 1

if __name__ == "__main__":
    main()
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

num = 7
for i in range(1,10**6):
    if num % k == 0:
        print(i)
        break
    num = (num % k) * 10 + 7
import sys

k = int(input())
n = 7
counter = 1
remainders = set()

while True:
    remainder = n % k
    if remainder == 0:
        print(counter)
        sys.exit()
    if remainder in remainders:
        print(-1)
        sys.exit()
    remainders.add(remainder)
    
    n = remainder * 10 + 7
    counter += 1
import time
start=time.time()
k=int(input())
ans=0
x=k
for i in range(10**9):
  while x%10!=7:
    x+=k
    if time.time()-start>=1.9:exit(print(-1))
  x//=10
  if x==0:exit(print(i+1))