Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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
while True:
    res = tmp % k
    if res==0:
        print(cnt)
        break
        sys.exit()
    else:
        if res not in reses:
            reses.append(res)
        else:
            print("-1")
            break
            sys.exit()
    tmp = res * 10 + 7
    cnt += 1

### FIXED CODE ###

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)
### BUGGY CODE ###

import math
from collections import Counter

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def main():
    n = int(input())
    array_s = []
    array = []
    for i in range(n):
        array_s.append(input())

    for s in array_s:
        array.append(Counter(s))

    ans = 0
    for i in range(n):
        if array:
            alphabet = array[:][0]
            num = array.count(alphabet)-1
            if num <= 0:
                pass
            elif num <= 1:
                ans += 1
            else:
                ans += combinations_count(num+1, 2)
            for j in range(num+1):
                array.remove(alphabet)
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    array_s = []
    array = []
    for i in range(n):
        array_s.append(input())

    for s in array_s:
        array.append(''.join(sorted(s)))
    array = sorted(array)
    ans = 0
    count = 1
    for i in range(n-1):
        if array[i] == array[i+1]:
            count += 1
            if i != n-2:
                continue
        ans += int(count*(count-1)/2)
        count = 1
    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
nums = list(map(int,input().split()))
nums.sort()
unique = []
for i in range(len(nums)):
  flag = 0
  for j in range(len(nums)):
    if i==j:
      continue
    if nums[i]%nums[j] == 0:
      flag = 1
  if flag ==0:
    unique.append(nums[i])
print(len(unique))


### FIXED CODE ###

n = int(input())
nums = list(map(int,input().split()))
nums.sort()
ans = 0
cnt = {}
flag = [0]*1000005
for i in nums:
  cnt[i] = cnt.get(i,0) + 1

for i in nums:
  if flag[i] == 0 and cnt[i] == 1:
    ans += 1
  if flag[i] == 1:
    continue
  for j in range(i,1000001,i):
    flag[j] = 1

print(ans)
### BUGGY CODE ###

N,P=map(int,input().split())
S=input()

a=[0]*(N+1)

if P!=2 and P!=5:
    for i in range(N):
        a[i] = int(S[i:])%P
    ans=0
    from collections import Counter
    C=Counter(a)
    for k,v in C.items():
        ans+=v*(v-1)//2
elif P==2:
    ans=0
    for i in range(N):
        if int(S[i])%2==0:
            ans+=i+1
elif P==5:
    ans=0
    for i in range(N):
        if int(S[i])==0 or int(S[i])==5:
            ans+=i+1

print(ans)



### FIXED CODE ###

N, P = map(int, input().split())
S = input()

a = [0] * (N + 1)

if P != 2 and P != 5:
    tenfactor=1
    for i in range(1,N+1):
        a[i] = ((int(S[N-i])*tenfactor+a[i-1])%P)
        tenfactor*=10
        tenfactor%=P

    ans = 0
    from collections import Counter
    C=Counter(a)
    for v,i in C.items():
        ans += (i * (i - 1) // 2)
elif P == 2:
    ans = 0
    for i in range(N):
        if int(S[i]) % 2 == 0:
            ans += i + 1
elif P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) == 0 or int(S[i]) == 5:
            ans += i + 1

print(ans)
### BUGGY CODE ###

h,*s=open(0)
h,w,k,*m=map(int,h.split())
b=512
while b:
 b-=1;r=t=j=0;d=[0]*h
 while w-j:
  i=c=0;j+=1
  while h-i:
   d[c]+=s[i][~j]>'0';c+=b>>i&1;i+=1
   if max(d)>k:d=[0]*h;r+=1;j-=t<j;t=j;i=h
 m+=r+c,
print(min(m))

### FIXED CODE ###

h,*s=open(0)
h,w,k=map(int,h.split())
s=[list(map(int,t[:w]))for t in s]
m=9e9
for i in range(1<<h-1):
  t=[]
  b=v=l=0
  for j in range(h):
    if i>>j&1:
      t+=s[b:j+1],
      b=j+1
      l+=1
  t+=s[b:],
  l+=1
  c=[0]*l
  for i in range(w):
    f=g=0
    u=[]
    for j in range(l):
      d=sum(t[i]for t in t[j])
      u+=d,
      if d>k:
        g=1
        break
      c[j]+=d
      f|=c[j]>k
    else:
      v+=f
      if f:c=u
    if g:break
  else:m=min(m,v+l-1)
print(m)
### BUGGY CODE ###

s = input()
t = input()
m = len(s)
n = len(t)
dp = [[0]*(n+1) for _ in range(m+1)]
for i in range(1,m+1):
    for j in range(1,n+1):
        x = s[i-1]
        y = t[j-1]
        if x == y:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = dp[i-1][j]
            if dp[i][j] < dp[i][j-1]:
                dp[i][j] = dp[i][j-1]
res = ""
while n != 0 and m != 0:
    if dp[m][n] == dp[m-1][n]:
        m -= 1
    elif dp[m][n] == dp[m][n-1]:
        n -= 1
    else:
        n -= 1
        m -= 1
        res = s[m] + res
print(res)

### FIXED CODE ###

s = input()
t = input()
m = len(s)
n = len(t)
dp = [[0]*(n+1) for _ in range(m+1)]
for i in range(1,m+1):
    for j in range(1,n+1):
        x = s[i-1]
        y = t[j-1]
        if x == y:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = dp[i-1][j]
            if dp[i][j] < dp[i][j-1]:
                dp[i][j] = dp[i][j-1]
res = ""
while n != 0 and m != 0:
    if dp[m][n] == dp[m-1][n]:
        m -= 1
    elif dp[m][n] == dp[m][n-1]:
        n -= 1
    else:
        n -= 1
        m -= 1
        res = s[m] + res
print(res)
### BUGGY CODE ###

n = int(input())
lst = []
for i in range(0,n):
  lst.append(int(input()))
  

for i in range(0,len(lst)):
  sort_lst = []
  for j in range(0,len(lst)):
    if not i == j:
      sort_lst.append(lst[j])
  sort_lst = sorted(sort_lst, reverse=True)
  print(sort_lst[0])

### FIXED CODE ###

n=int(input())
a=[int(input())for _ in range(n)]
b=sorted(a) # sortする降順に

for a in a:print(b[(a<b[-1])-2])
### BUGGY CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
new_p = []
temp = 0
temp_max = 0
    
for i in range(len(p) - k + 1):
    if temp_max < sum(p[i:i + k]):
        temp_max = sum(p[i:i + k])
        temp = i

for i in p[temp:temp + k]:
    new_p.append(((i * (i + 1)) / 2) / i)

print(sum(new_p)) 

### FIXED CODE ###

from itertools import accumulate

n, k = map(int, input().split())
p = list(map(int, input().split()))

new_p = []
temp = []
for i in p:
    new_p.append(((i * (i + 1)) / 2) / i)
q = [0] + new_p
q = list(accumulate(q))

for i in range(len(q) - k):
    temp.append(q[i + k] - q[i])
print(max(temp))
### BUGGY CODE ###

N, M = map(int, input().split())
a_list = list(map(int, input().split()))
written_pairs = [None] * M

for i in range(M):
    b, c = map(int, input().split())
    a_list += [c] * b

a_list = sorted(a_list, reverse = True)

print(sum(a_list[:N]))


### FIXED CODE ###

#TLE
N, M = map(int, input().split())
a_list = list(map(int, input().split()))

written_nums = []
for i in range(M):
    b, c = map(int, input().split())
    written_nums.append((c, b))

written_nums.sort(reverse = True)
append_list = []
for c, b in written_nums:
    append_list += [c for _ in range(b)]

    if len(append_list) >= N:
        break

a_list += append_list
a_list.sort(reverse = True)

print(sum(a_list[:N]))
### BUGGY CODE ###

line_one = raw_input().split()
n = int(line_one[0])
k = int(line_one[1])

arr = []
for i in range(n):
    line = raw_input().split()
    a = int(line[0])
    b = int(line[1])
    arr += [a] * b

arr = sorted(arr)
print arr[k-1]


### FIXED CODE ###

def main():
    n, k = [int(x) for x in input().split(' ')]
    arr = [0] * 100001
    for _ in range(n):
        a, b = [int(x) for x in input().split(' ')]
        arr[a] += b
    foo = 0
    for i, e in enumerate(arr):
        foo += e
        if (foo >= k):
            print(i)
            break

main()
### BUGGY CODE ###

n , m=map(int,input().split())
l1 , r1 =map(int,input().split())
A =set(range(l1,r1+1))

for i in range(m-1):
    l , r =map(int,input().split())
    B = set(range(l,r+1))
    A = A.intersection(B)
print(len(A))

### FIXED CODE ###

n , m = map(int,input().split())
L = []
R = []
for i in range(m):
    l , r = map(int,input().split())
    L.append(l)
    R.append(r)
Lmax = max(L)
Rmin = min(R)
s = range(Lmax,Rmin+1)
print(len(s))
### BUGGY CODE ###

import fractions
import itertools
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

n = int(input())
a = [int(x) for x in input().split()]

tmp = 0
for v in itertools.permutations(a, len(a)-1):
    tmp = max(gcd(*v), tmp)

print(tmp)

### FIXED CODE ###

import fractions
import itertools
from functools import reduce

n = int(input())
a = [int(x) for x in input().split()]

l = [0]*(n+1)
r = [0]*(n+1)

for i in range(n):
    l[i+1] = fractions.gcd(l[i], a[i])
    r[n-i-1]= fractions.gcd(r[n-i], a[n-i-1])

ans = 0
for i in range(n):
    ans = max(fractions.gcd(l[i], r[i+1]), ans)

print(ans)
### BUGGY CODE ###

#input
N = int(input())
A = list(map(int, input().split()))

#output
import fractions
import  functools
import numpy as np

mod = 10**9 + 7

gcd = functools.reduce(fractions.gcd, A)

def lcm_base(x, y):
    return (x*y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)

lcm =  lcm_list(A)

answer = 0
for i in range(N):
    answer += lcm//A[i] % mod

print(answer % mod)

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
#input
N = int(input())
A = list(map(int, input().split()))
 
#output
import fractions, functools
 
def lcm_base(x, y):
    return (x*y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return functools.reduce(lcm_base, numbers, 1)
 
lcm = lcm_list(A)
 
answer = 0
for i in range(N):
    answer += lcm//A[i]
 
print(answer % (10**9 + 7))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys, os

def main():
    inp = [int(x) for x in os.read(0, os.fstat(0).st_size).split()]
    n, m = inp[0],inp[1]

    wi, vi = inp[2], inp[3]


    dp = [0] * (m + 1)
    for j in range(wi, m + 1):
        dp[j] = vi

    for i in range(n - 1):
        wi = inp[2*i + 4]
        vi = inp[2*i + 5]
        for j in reversed(range(wi, m + 1)):
            if dp[j] < vi + dp[j - wi]:
                dp[j] = vi + dp[j - wi]

    print(dp[-1])
main()

### FIXED CODE ###

#!/usr/bin/env python3
import sys, os
range = xrange

def main():
    inp = [int(x) for x in os.read(0, os.fstat(0).st_size).split()]
    n, m = inp[0],inp[1]

    w, v = inp[2::2], inp[3::2]

    dp = [0] * (m + 1)
    for j in range(w[0], m + 1):
        dp[j] = v[0]

    for i in range(n - 1):
        vi = v[i + 1]
        wi = w[i + 1]
        for j in reversed(range(wi, m + 1)):
            dp[j] = max(vi + dp[j - wi], dp[j])

    print(dp[-1])
main()
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(0,n):
    b[i] = a.index(i+1) + 1
print(" ".join(map(str,b)))


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(0,n):
    b[a[i]-1] = i + 1
print(*b)
### BUGGY CODE ###

n= int(input())
l=list(map(int,input().split()))

flag=[0]*n

for i in range(len(l)):
    for j in range(len(l)):
        if i==j:
            continue
        elif flag[i]==1:
            continue
        elif l[i]%l[j]==0:
            flag[i]=1
            break
print(flag.count(0))


### FIXED CODE ###

n= int(input())
l=list(map(int,input().split()))

l.sort()
maxnum=l[len(l)-1]
flag=[0]*(maxnum+1)

for num in l:
    flag[num]+=1
    if flag[num]>1:
        continue
    for j in range(num*2, maxnum+1, num):
        flag[j]+=1
#print(flag)
ans=0

for num in l:
    if flag[num]==1:
        ans+=1
print(ans)
### BUGGY CODE ###

# AOJ 1105: Unable Count
# Python3 2018.7.14 bal4u

while True:
	n, a, b = map(int, input().split())
	if n == 0: break
	f = [0]*(n<<1)
	for x in range(0, n, a):
		for y in range(0, n+1, b): f[x+y] = 1
	print(n-sum(f[1:n+1]))


### FIXED CODE ###

# AOJ 1105: Unable Count
# Python3 2018.7.14 bal4u

while True:
	n, a, b = map(int, input().split())
	if n == 0: break
	f = [0]*(n+max(a,b)+1)
	f[0], f[a], f[b] = 1, 1, 1
	s = min(a, b)
	for k in range(s, n+1):
		if f[k]: f[a+k] = 1; f[b+k] = 1
	print(n-sum(f[s:n+1]))
### BUGGY CODE ###

import re

N,Q = list(map(int,input().split()))
s = input()
lis=[]


for i in range(len(s)):
    count = 0
    for m in re.findall(r'AC', s[:i+1]):
        count += 1
    lis.append(count)
for i in range(Q):
    l,r = list(map(int,input().split()))
    print(lis[r-1]-lis[l-1])


### FIXED CODE ###

import re
 
N,Q = list(map(int,input().split()))
s = input()
lis=[0]
 
count = 0
for i in range(1,len(s)):
    if s[i-1] == 'A' and s[i] == 'C':
        count +=1
    lis.append(count)
for i in range(Q):
    l,r = list(map(int,input().split()))
    print(lis[r-1]-lis[l-1])
### BUGGY CODE ###

#import itertools
#K = int(input())
#N,K = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))
c=0
for i in range(N):
    s=i+A[i]+1
    if s>N:
        continue
    for j in range(s,N):
        if abs(i-j)==A[i]+A[j]:
            c+=1

print(c)


### FIXED CODE ###

from collections import Counter
#K = int(input())
#N,K = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))
c=0
l=[]
r=[]
for i in range(N):
    l.append(A[i]+i+1)
    r.append(i+1-A[i])

C=Counter(r)

for x in l:
    c+=C.get(x,0)
print(c)
### BUGGY CODE ###

MOD = 10**9 + 7
N = int(input())
dp = [0] * (1 << N)
dp[0] = 1
prev = [0]
for i in range(N):
    temp = []
    for bit in [1 << i for i, v in enumerate(input().split()) if v == '1']:
        for s in prev:
            if s & bit == 0:
                new_s = s | bit
                dp[new_s] += dp[s]
                dp[new_s] %= MOD
                temp.append(new_s)
    prev = list(set(temp))
print(dp[(1 << N) - 1])

### FIXED CODE ###

MOD = 10**9 + 7
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
dp = [0] * (1 << N)
dp[0] = 1
bits = [1 << i for i in range(N)]
cands = [[] for _ in range(N+1)]
for s in range(1 << N):
    temp = 0
    for n in range(N):
        if s & (1 << n): temp += 1
    cands[temp].append(s)
for i, a in enumerate(A):
    for j in [k for k, v in enumerate(a) if v == 1]:
        bit = bits[j]
        for s in cands[i]:
            if s & bit == 0:
                new_s = s | bit
                dp[new_s] += dp[s]
                dp[new_s] %= MOD
print(dp[-1])
### BUGGY CODE ###

a, b, c, d = map(int, input().split())
ans = -float('inf')
for x in range(a, b+1):
  for y in range(c, d+1):
    xy = x*y
    ans = max(ans, xy)
print(ans)

### FIXED CODE ###

a, b, c, d = map(int, input().split())
print(max(a*c, a*d, b*c, b*d))
### BUGGY CODE ###

n, k = map(int, input().split())
vs = list(map(int, input().split()))

from collections import deque
from heapq import heappush, heappop
from itertools import product

res = 0

for comb in product([1, 2, 3, 4], repeat=k):
    dq = deque(vs)
    hq = []
    valid = True
    for i in range(k):
        s = comb[i]
        if s == 1:
            if len(dq) > 0:
                heappush(hq, dq.popleft())
            else:
                valid = False
                break
        elif s == 2:
            if len(dq) > 0:
                heappush(hq, dq.pop())
            else:
                valid = False
                break
        elif s == 3:
            if len(hq) > 0:
                dq.appendleft(heappop(hq))
            else:
                valid = False
                break
        else:
            if len(hq) > 0:
                dq.append(heappop(hq))
            else:
                valid = False
                break
    if valid:
        res = max(res, sum(hq))

print(res)

### FIXED CODE ###

n, k = map(int, input().split())
vs = list(map(int, input().split()))

from collections import deque
from heapq import heappush, heappop

res = 0

for i in range(0, min(k, n) + 1):
    for j in range(i + 1):
        a = j
        b = i - j

        hq = []
        dq = deque(vs)

        for _ in range(a):
            heappush(hq, dq.popleft())
        for _ in range(b):
            heappush(hq, dq.pop())

        c = k - a - b
        for _ in range(c):
            if len(hq) == 0:
                break
            v = heappop(hq)
            if v > 0:
                heappush(hq, v)
                break

        res = max(res, sum(hq))

print(res)
### BUGGY CODE ###

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ship_list1 = []
ship_list2 = []
count = 0
loop = False

for i in range(m):
    if ab[i][0] == 1:
        ship_list1.append(ab[i])
    if ab[i][1] == n:
        ship_list2.append(ab[i])

for ship1 in ship_list1:
    for ship2 in ship_list2:
        if ship1[1] == ship2[0]:
            print('POSSIBLE')
            count += 1
            loop = True
            break
    if loop:
        break

if count == 0:
    print('IMPOSSIBLE')

### FIXED CODE ###

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

ship_list1 = []
ship_list2 = []
count = 0
loop = False

for i in range(m):
    if ab[i][0] == 1:
        ship_list1.append(ab[i][1])
    if ab[i][1] == n:
        ship_list2.append(ab[i][0])

if len(set(ship_list1) & set(ship_list2)) >= 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
### BUGGY CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x

        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def members(self, x, except_list):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root and i not in except_list]

def solve(uf, first_order_friends):
    ret = [0]
    for i in range(1, N + 1):
        ret.append(len(uf.members(i, first_order_friends[i])) - 1)
    return ret

if __name__ == '__main__':
    N, M, K = map(int, input().split())
    first_order_friends = [set() for _ in range(N + 1)]
    blocked_list = [set() for _ in range(N + 1)]
    uf = UnionFind(N + 1)

    for _ in range(M):
        a, b = map(int, input().split())
        first_order_friends[a].add(b)
        first_order_friends[b].add(a)
        uf.union(a, b)

    for _ in range(K):
        c, d = map(int, input().split())
        first_order_friends[c].add(d)
        first_order_friends[d].add(c)

    for ans in solve(uf, first_order_friends)[1:]:
        print(ans, end=' ')

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x

        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

def solve(uf, except_list):
    ret = [0]
    for i in range(1, N + 1):
        ret.append(uf.size(i) - 1 - len(except_list[i]))
    return ret

if __name__ == '__main__':
    N, M, K = map(int, input().split())
    except_list = [[] for _ in range(N + 1)]
    uf = UnionFind(N + 1)

    for _ in range(M):
        a, b = map(int, input().split())
        except_list[a].append(b)
        except_list[b].append(a)
        uf.union(a, b)

    for _ in range(K):
        c, d = map(int, input().split())
        if not uf.same(c, d):
            continue
        except_list[c].append(d)
        except_list[d].append(c)

    for ans in solve(uf, except_list)[1:]:
        print(ans, end=' ')
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
#まずk学期までの
p=1
for i in range(k):
    p*=a[i]


for i in range(n-k):
    tmp=p
    p//=a[i]
    p*=a[i+k]
    #print(p)
    if p>tmp:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))

for i in range(n-k):

    if a[i]<a[k+i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

S=list(input())
l = len(S)
i = 0
j = -1
ans = 0
while i<l:
    if j==-1 and S[i] == "A":
        j=i
        i+=1
    elif j>=0 and S[i] == "A":
        i+=1
    elif j>=0:
        if len(S[i:i+2])==2 and S[i] == "B" and S[i+1] == "C":
            S[j:i+2] = list("BC")+["A"]*(i-j)
            ans += i-j
            i = j
            j = -1
        else:
            j = -1
            i+=1
    else:
        i+=1
print(ans)

### FIXED CODE ###

S=input().replace("BC","D").replace("B","C").split("C")
ans = 0
for s in S:
    a = 0
    for c in s:
        if c == "A":a+=1
        else:ans += a
print(ans)
### BUGGY CODE ###

N, M = [int(str) for str in input().strip().split()]

for i in range(N, M + 1):
    if M % i == 0:
        print(M // i)
        exit()

print(1)

### FIXED CODE ###

#!/usr/bin/env python3
N, M = [int(str) for str in input().strip().split()]

divs = []
for i in range(1, int(M**0.5) + 1):
    if M % i == 0:
        divs.append(i)
        if i**2 != M:
            divs.append(M // i)

divs.sort(reverse=True)

for div in divs:
    if M // div >= N:
        print(div)
        exit()
### BUGGY CODE ###

k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    if(m%k==0):
      print(i)
      break  
    if(i>10000000):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1



### FIXED CODE ###

k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    m = m%k
    if(m==0):
      print(i)
      break  
    if(i>k):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1