Harryxun/stf_run huggingface dataset:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    # ABC174-F

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

    Bsize = int(N ** 0.5) + 1
    query = []
    for q in range(Q):
        l, r = map(int, input().split())
        query.append((l - 1, r - 1, q, l // Bsize))
    query.sort(key=lambda x: x[1])
    query.sort(key=lambda x: x[3])

    # [l, r)での求める値を管理するための変数たち
    # 問題によって変える
    cnt = [0] * (N + 1)
    val = 0

    # 区間の伸縮操作
    # 問題によって変える
    def add(i):
        global val
        cnt[A[i]] += 1
        if cnt[A[i]] == 1:
            val += 1

    def rem(i):
        global val
        cnt[A[i]] -= 1
        if cnt[A[i]] == 0:
            val -= 1

    # init
    l, r, _, _ = query[0]
    for i in range(l, r + 1):
        add(i)

    # process
    ans = [0] * Q
    for l_new, r_new, q, _ in query:
        if r < r_new:
            for i in range(r + 1, r_new + 1):
                add(i)
        elif r > r_new:
            for i in range(r, r_new, -1):
                rem(i)
        if l < l_new:
            for i in range(l, l_new):
                rem(i)
        elif l > l_new:
            for i in range(l - 1, l_new - 1, -1):
                add(i)
        l = l_new
        r = r_new
        ans[q] = val

    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


### FIXED CODE ###

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    class Bit:
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x):
            while i <= self.size:
                self.tree[i] += x
                i += i & -i

        def lower_bound(self, w):
            if w <= 0:
                return 0
            x = 0
            k = 1 << (self.size.bit_length() - 1)
            while k:
                if x + k <= self.size and self.tree[x + k] < w:
                    w -= self.tree[x + k]
                    x += k
                k >>= 1
            return x + 1

    N, Q = map(int, input().split())
    C = list(map(int, input().split()))
    query = []
    for q in range(Q):
        query.append(list(map(int, input().split())))
        query[-1].append(q)
    query.sort(key=lambda x: x[1])

    last = [0] * (N+1)
    for i, c in enumerate(C):
        if i > query[0][1]-1:
            break
        last[c] = i+1

    bit = Bit(N)
    for i in range(1, N+1):
        if last[i]:
            bit.add(last[i], 1)
    r_prev = query[0][1]
    ans = [0] * Q
    for l, r, q in query:
        if r > r_prev:
            for i in range(r_prev+1, r+1):
                j = last[C[i-1]]
                if j:
                    bit.add(j, -1)
                last[C[i-1]] = i
                bit.add(i, 1)
            r_prev = r
        ans[q] = bit.sum(r) - bit.sum(l-1)

    for a in ans:
        print(a)


if __name__ == '__main__':
    main()
n = int(input())
a = list(map(int, input().split()))
s = 1
for i in a:
  s *= i
  if s => 10 ** 8:
    s = -1
    break
if 0 in n:
  s = 0
print(s)
 

### FIXED CODE ###

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

ans = 1
for i in a :
  ans *= i
  if ans > 10**18 :
    ans = -1
    break
if 0 in a :
  ans = 0

print(ans)
h, w = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]

cnt = 0
ans = []
for i in range(h):
    for j in range(w):
        a = A[i][j]
        if a%2 == 1:
            for dy, dx in (-1, 0), (0, -1), (0, 1), (1, 0):
                ni = i+dy
                nj = j+dx
                if 0 <= ni < h and 0 <= nj < w:
                    ni_ = ni
                    nj_ = nj
                    if A[ni][nj]%2 == 1:
                        A[ni][nj] += 1
                        A[i][j] -= 1
                        cnt += 1
                        ans.append([i+1, j+1, ni+1, nj+1])
                        break
            else:
                A[ni_][nj_] += 1
                A[i][j] -= 1
                cnt += 1
                ans.append([i+1, j+1, ni_+1, nj_+1])

print(cnt)
for i in range(cnt):
    print(*ans[i])


### FIXED CODE ###

h, w = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]

if h == 1 and w == 1:
    print(0)
    exit()

cnt = 0
ans = []
for i in range(h):
    for j in range(w):
        a = A[i][j]
        if a%2 == 1:
            for dy, dx in (-1, 0), (0, -1), (0, 1), (1, 0):
                ni = i+dy
                nj = j+dx
                if 0 <= ni < h and 0 <= nj < w:
                    ni_ = ni
                    nj_ = nj
                    if A[ni][nj]%2 == 1:
                        A[ni][nj] += 1
                        A[i][j] -= 1
                        cnt += 1
                        ans.append([i+1, j+1, ni+1, nj+1])
                        break
            else:
                A[ni_][nj_] += 1
                A[i][j] -= 1
                cnt += 1
                ans.append([i+1, j+1, ni_+1, nj_+1])

print(cnt)
for i in range(cnt):
    print(*ans[i])
# -*- coding: utf-8 -*-
def stairs_count(now, goal, memo):
    if now == goal:
        return 1
    if now > goal:
        return 0

    if memo[now] is not None:
        return memo[now]

    step1 = 0
    step2 = 0

    # step1
    if now + 1 == goal:
        step1 = 1
    else:
        step1 = stairs_count(now+1, goal, memo)

    # step2
    if now + 2 > goal:
        step2 = 0
    elif now + 2 == goal:
        step2 = 1
    else:
        step2 = stairs_count(now+2, goal, memo)

    memo[now] = (step1 + step2) % 1000000007
    return memo[now]


n, m  = map(int, input().split())
memo = [None for _ in range(n)]
for _ in range(m):
    a = int(input())
    memo[a] = 0

root = stairs_count(0, n, memo)
print(root)


### FIXED CODE ###

# -*- coding: utf-8 -*-
mod = 1000000007

n, m  = map(int, input().split())
dp = [0 for _ in range(n+1)]
broken = [False for _ in range(n+1)]
for _ in range(m):
    a = int(input())
    broken[a] = True

dp[0] = 1
dp[1] = 0 if broken[1] else 1
for i in range(2, n+1):
    if broken[i]:
        continue
    if not broken[i-2]:
        dp[i] += dp[i-2]
        dp[i] %= mod
    if not broken[i-1]:
        dp[i] += dp[i-1]
        dp[i] %= mod

print(dp[n])
a=[0]*5
for i in range(5):
  a[i]=int(input())
b=int(input())
if a[5]-a[0]>b:
  print(':(')
else:
  print('Yay!')
  


### FIXED CODE ###

a=[0]*5
for i in range(5):
  a[i]=int(input())
b=int(input())
if a[4]-a[0]>b:
  print(':(')
else:
  print('Yay!')
S1 = input()
S2 = '2' + S1[0]
res = 0

for s in S1[1::]:
    if S2[-1] == s:
        S2 += s
    else:
        S2 = S2[:-1:]
        res += 2

print(res)


### FIXED CODE ###

S1 = input()
S2 = ''
res = 0

for s in S1:
    if len(S2) == 0 or S2[-1] == s:
        S2 += s
    else:
        S2 = S2[:-1:]
        res += 2

print(res)
s = int(input())

ans = 0

if (s == 1 || s == 2 || s == 4):
  print(4)

while (s != 4):
  if (s % 2 == 0):
    s /= 2
  else:
    s = 3*s + 1
  ans += 1

print(ans+4)


  

### FIXED CODE ###

s = int(input())
 
ans = 0
 
if (s == 1 or s == 2 or s == 4):
  print(4)
else:
  while (s != 4):
    if (s % 2 == 0):
      s  =  int(s/2)
    else:
      s = 3*s + 1
    ans += 1
  
 
  print(ans+4)
s=input()
if s[0]=="Y" and s[1]=="A" and s[2]=="K" and s[3]=="I":
    print("Yes")
else:
    print("No")


### FIXED CODE ###

s=input()
try:
    if s[0]=="Y" and s[1]=="A" and s[2]=="K" and s[3]=="I":
      print("Yes")
    else:
        print("No")
except:
    print("No")
from networkx import*
f=lambda:tuple(map(int,input().split()))
n,m=f()
print(max(map(len,connected_components(Graph(f()for _ in range(m))))))

### FIXED CODE ###

from networkx import*
_,*t=map(str.split,open(0))
print(max(1,1,*map(len,connected_components(Graph(t)))))
import math
# i=int(input())
#n,m=map(int, input().split())
r = int(input())
print(r*2*math.pi)


### FIXED CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
print(-1 if n-sum(a) < 0 else n-sum(a))
n, k = map(int, input().split())
s = []
for i in range(k):
    l, r = map(int, input().split())
    s += list(range(l, r+1)

mod = 998244353
dp = [0] * (n+1)
dp[1] = 1
s = sorted(s)
for i in range(1, n):
    dp[i] %= mod
    for add in s:
        if i+add <= n:
            dp[i+add] += dp[i]
print(dp[n] % mod)

### FIXED CODE ###

n, k = map(int, input().split())
s = []
for i in range(k):
    l, r = map(int, input().split())
    s.append([l, r])

mod = 998244353
dp = [0] * (n+1)
cumsum = [0] * (n+1)

dp[1] = 1
s = sorted(s)
counter = 0
for i in range(1, n+1):
    counter += cumsum[i]
    dp[i] += counter
    dp[i] %= mod
    for l, r in s:
        if i+l <= n:
            cumsum[i+l] += dp[i]
        if i+r+1 <= n:
            cumsum[i+r+1] -= dp[i]
print(dp[n] % mod)
i = int(raw_input())

while (i):
	i -= 1
	st = []
	n = raw_input()

	for s in n:
		st.append(s)

	st.sort()
	a = int("".join())
	b = int("".join(st[::-1]))

	print b - a

### FIXED CODE ###

i = int(raw_input())

while (i):
	i -= 1
	st = []
	n = raw_input()

	for s in n:
		st.append(s)

	st.sort()
	a = int("".join(st))
	b = int("".join(st[::-1]))

	print b - a
dict={}
output=[]

iteration=int(input())
for _ in range(iteration):
    item=input()
    
    if dict.get(item) is None:
        dict[item]=0 
    dict[item]+=1 
max_val=max(dict.values())
for i in range(iteration):
    max_key=max(dict,key=dict.get)
    if(max_val!=dict[max_key]):
        break
    output.append(max_key)
    
    del dict[max_key]
output.sort()
print('\n'.join(output))

### FIXED CODE ###

n = int(input())
dic = {}
for i in range(n):
    s = input()
    try:
        dic[s] += 1
    except:
        dic[s] = 1
high=max(dic.values())
val= sorted(dic.items())
for i in val:
    if(i[1]==high):
        print(i[0])
import sys
readline = sys.stdin.buffer.readline
N=int(readline().strip())
n=[str(i) for i in range(1,N+1)]
cnt=0
for i in n:
  for j in n:
    if i[0]==j[-1] and i[-1]==j[0]:
      cnt+=1
print(cnt)


### FIXED CODE ###

N,M=input().split()
print('Yes' if N == M else 'No')
N = int(input())

l = [1, 2]

for i in range(N-1):
  l = l.append(l[i]+l[i+1])
  
print(l[-1])

### FIXED CODE ###

N = int(input())

l = [2, 1]

for i in range(N-1):
  l.append(l[i]+l[i+1])
  
print(l[-1])
n = int(input())
int count = 0
p[] = map(int,input(),split())
for (i=0; i < n-2; i++){
  if p[i] < p[i+1] < p[i+2]: count ++;}
print(count)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
ans = sum(1 for i in range(n-2) if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2])
print(ans)
N = int(input())

 ans = 0
 for i in range(N):
   x,u=map(str, input().split())
   if u == "JPY":
     ans += float(x)
   else:
     ans += float(x) * 380000.0

 print(ans)


### FIXED CODE ###

N = int(input())

ans = 0
for i in range(N):
  x,u=map(str, input().split())
  if u == "JPY":
    ans += float(x)
  else:
    ans += float(x) * 380000.0

print(ans)
import math

r = int(input())

print(f' {math.pi * r ** 2} {math.pi * r * 2}')



### FIXED CODE ###

import math

r = float(input())

print(f' {math.pi * r ** 2} {math.pi * r * 2}')
import bisect

N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for i in range(M)]

A.sort()
BC.sort(key=lambda x: x[1],reverse=True)
ans=0
for j in range(M):
    if A[0]>=BC[j][1]:
        break
    else:
        b=BC[j][0]
        c=BC[j][1]
        R=bisect.bisect_left(A,c)
        if R>=b:
            A[0:b]=[]
            ans+=b*c
        else:
            A[0:R]=[]
            ans+=R*c
print(sum(A)+ans)

### FIXED CODE ###

import bisect

N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for i in range(M)]

A.sort()
BC.sort(key=lambda x: x[1],reverse=True) 
ans=0
for j in range(M):
    if A[0]>=BC[j][1]:
        break
    else:
        b=BC[j][0]
        c=BC[j][1]
        R=bisect.bisect_left(A,c)
        n=len(A)
        if R>b:
            if n<=b:
                A=[]
                ans+=n*c
                break
            else:
                del A[0:b]
                ans+=b*c
        else:
            del A[0:R]
            ans+=R*c
    if len(A)==0:
        break        
print(sum(A)+ans)
N = int(input())
Problems = list(map(int,input().split()))
M = int(input())
for i in range(M):
    p,t = map(int,input().split())
    Problems[p] = t
    print(sum(Problems))


### FIXED CODE ###

N = int(input())
Problems = list(map(int,input().split()))
M = int(input())
for i in range(M):
    p,t = map(int,input().split())
    k = Problems[p-1]
    Problems[p-1] = t
    print(sum(Problems))
    Problems[p-1] = k
import math
from sympy import divisor_count
N = int(input())
N = math.factorial(N)
mod = 10**9+7

print(divisor_count(N) % mod)


### FIXED CODE ###

inp = input()
a, b, c, d = inp.split(' ')

if int(a) * int(b) > int(c) * int(d):
    print(int(a) * int(b))
else:
    print(int(c) * int(d))
def bw(i, p):
    if dp[i] != [0, 0]:
        return dp[i]
    b = w = 1
    for ii in h[i]:
        if ii in p: continue
        bwi = bw(ii, p + [ii])
        w *= (bwi[0] + bwi[1])
        b *= bwi[1]
        w %= md
        b %= md
    dp[i] = [b, w]
    return [b, w]


md = 10 ** 9 + 7
n = int(input())
if n == 1:
    print(2)
    exit()
h = {}
for _ in range(n - 1):
    a, b = map(int, input().split())
    h.setdefault(a, [])
    h.setdefault(b, [])
    h[a] += [b]
    h[b] += [a]
dp = [[0, 0] for _ in range(n + 1)]
b, w = bw(1, [1])
print((b + w) % md)


### FIXED CODE ###

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def bw(i, p):
    if dp[i] != [0, 0]:
        return dp[i]
    b = w = 1
    for ii in h[i]:
        if ii == p: continue
        bwi = bw(ii,i)
        w *= (bwi[0] + bwi[1])
        b *= bwi[1]
        w %= md
        b %= md
    dp[i] = [b, w]
    return [b, w]


md = 10 ** 9 + 7
n = int(input())
if n == 1:
    print(2)
    exit()
h = {}
for _ in range(n - 1):
    a, b = map(int, input().split())
    h.setdefault(a, [])
    h.setdefault(b, [])
    h[a] += [b]
    h[b] += [a]
dp = [[0, 0] for _ in range(n + 1)]
b, w = bw(1, 1)
print((b + w) % md)
def cal(a, op, b):

  if op == '+':
    r = a + b
  elif op == '-':
    r = a + b
  elif op == '*':
    r = a * b
  elif op == '/':
    r = a / b

while 1:
  a,op,b = raw_input().split()
  if op == '?':
    break
  else:
    cal(int(a), op, int(b))
  print r

### FIXED CODE ###

def cal(a, op, b):

  if op == '+':
    r = a + b
  elif op == '-':
    r = a - b
  elif op == '*':
    r = a * b
  elif op == '/':
    r = a / b
  return r

while 1:
  a,op,b = raw_input().split()
  if op == '?':
    break
  else:
    print(cal(int(a), op, int(b)))
from collections import deque


N, M, K = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))
now = 0
ans = 0

while A:
    i = 0
    while A[0] > B[i]:
        i += 1
    B.insert(i, A.popleft())

for time in B:
    now += time
    if now > K:
        break
    ans += 1

print(ans)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
import sys
input = sys.stdin.readline
"""
in1 = '5'
in2 = '7 2 3 8 5'
in3 = '3'
in4 = ['4 2', '1 7', '4 13']

N = int(in1)
T_N = list(map(int, in2.split()))
M = int(in3)
P_M = [None] * M
X_M = [None] * M
for i in range(M):
    P_M[i], X_M[i] = (int(x) for x in in4[i].split())
"""
N = int(input())
T_N = list(map(int, input().split()))
M = int(input())
P_M = [None] * M
P_X = [None] * M
for i in range(M):
    P_M[i], X_M[i] = (int(x) for x in input().split())

sumT = sum(T_N)
for idx1 in range(M):
    print(sumT - T_N[P_M[idx1] - 1] + X_M[idx1])


### FIXED CODE ###

import sys
in1 = sys.stdin.readlines()

#in1 = ['5','7 2 3 8 5','3','4 2','1 7','4 13']

N = int(in1[0])
T_N = list(map(int, in1[1].split()))
M = int(in1[2])
P_M = [None] * M
X_M = [None] * M
idx1 = 0
for PX in in1[3:]:
    P_M[idx1], X_M[idx1] = map(int, PX.split())
    idx1 += 1

sumT = sum(T_N)
for idx1 in range(M):
    print(sumT - T_N[P_M[idx1] - 1] + X_M[idx1])
lis=list(map(int,input().split()))
mod=(10**9)+7
pascal=[]
for i in range(lis[0]):
    pascal.append([])
    for j in range(i+2):
        if j==0 or j==i+1:
            pascal[i].append(1)
        else:
            pascal[i].append(pascal[i-1][j-1]+pascal[i-1][j])

for i in range(1,1+lis[1]):
    ans=pascal[lis[0]-lis[1]][i]*pascal[lis[1]-2][i-1]%mod
    print(ans)


### FIXED CODE ###

lis=list(map(int,input().split()))
mod=(10**9)+7
pascal=[]
#print(lis[0]-lis[1]+1,lis[1]-1)
rank=max(lis[0]-lis[1]+1,lis[1]+1)
for i in range(rank):
    pascal.append([])
    for j in range(i+2):
        if j==0 or j==i+1:
            pascal[i].append(1)
        else:
            pascal[i].append(pascal[i-1][j-1]+pascal[i-1][j])
#print(len(pascal[-1]))
for i in range(1,1+lis[1]):
    if i<=lis[0]-lis[1]+1:
        ans=pascal[lis[0]-lis[1]][i]*pascal[lis[1]-2][i-1]%mod
    else:
        ans=0
    print(ans)
import fractions

N = int(input())
T = []

for i in range(N):
    T.append(int(input()))

T.sort
a = T[0]

for i in range(N-1):
    gcd = fractions.gcd(a, T[i+1])
    a = int(a * T[i+1] / gcd)

print(int(a)) 


### FIXED CODE ###

N = int(input())
T = []

for i in range(N):
    T.append(int(input()))

a = 1

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

for i in range(N):
    a = a * T[i] // gcd(a,T[i])

print(a)
N,X=map(int,input().split())
L=list(map(int,input().split()))
count=0
length=0
while length<=X:
	length=length+L[count]
	count=count+1
print(count)

### FIXED CODE ###

N,X=map(int,input().split())
L=list(map(int,input().split()))
count=0
length=0
while length<=X:
	count=count+1
	if count==N+1:
		break
	length=length+L[count-1]
print(count)
import numpy as np
import sys

def main():
    n, q = map(int, input().split())
    ab = [[],[]]
    
    for i in range(n-1):
        na,nb = map(int, input().split())
        ab[0].append(na)
        ab[1].append(nb)

    px = [[],[]]
    for i in range(q):
        np,nx = map(int, input().split())        
        px[0].append(np)
        px[1].append(nx)
    
    # print(n,q,ab,px)
    count = [0 for i in range(n)]

    lgth = max(ab[0])
    node =[[] for i in range(lgth)]
    for i in range(n-1):
        index = ab[0][i]-1
        put = ab[1][i]
        node[index].append(put)

    # print(node)
    def calc(idx,val):
        count[idx] += val

        if idx <= lgth-1:
            for j in node[idx]:
                calc(j-1,val)
        
    for i in range(len(px[0])):    
        calc(px[0][i]-1, px[1][i])
    
    print(' '.join(map(str,count)))


if __name__ == '__main__':
    main()

### FIXED CODE ###

import numpy as np
import sys
from functools import lru_cache

def main():
    n, q = map(int, input().split())
    ab = [[],[]]
    
    for i in range(n-1):
        na,nb = map(int, input().split())
        ab[0].append(na)
        ab[1].append(nb)

    px = [[],[]]
    for i in range(q):
        np,nx = map(int, input().split())        
        px[0].append(np)
        px[1].append(nx)
    
    # print(n,q,ab,px)
    count = [0 for i in range(n)]

    oya_list = [0 for i in range(n)]
    for i in range(len(ab[1])):
        oya_list[ab[1][i]-1] = ab[0][i]
    
    for i in range(len(px[1])):
        count[px[0][i]-1] += px[1][i]
        
    for i in range(1,n):

        count[i] += count[oya_list[i]-1]
    
    print(' '.join(map(str,count)))


if __name__ == '__main__':
    main()
s=input()
dic={}
key_letters=[]
flag=0
for letter in s:
    if letter not in dic.keys():
        dic[letter]=1
    else:
        dic[letter]+=1
for key,value in dic.items():
    if value>=len(s)/2:
        key_letters.append(key)
        flag=1

if flag==0:
    print('-1 -1')
else:
    for i in range(len(s)):
        if s[i] in key_letters and s[i]==s[i+1]:
            print(str(i+1)+' '+str(len(s)))
            break



        


### FIXED CODE ###

s=input()
flag=0
if len(s)==2:
    if s[0]==s[1]:
        print('1 2')
    else:
        print('-1 -1')
else:
    for i in range(len(s)-2):
        if s[i]==s[i+2] and s[i]!=s[i+1]:
            print(str(i+1)+' '+str(i+3))
            flag=1
            break
        elif s[i]==s[i+1] and s[i]!=s[i+2]:
            print(str(i+1)+' '+str(i+3))
            flag=1
            break
        elif s[i+1]==s[i+2] and s[i+1]!=s[i]:
            print(str(i+1)+' '+str(i+3))
            flag=1
            break
    if flag==0:
        print('-1 -1')
import os
from sys import stdin

seq = list(map(int, stdin.readline().split()))
for i in range(len(seq)):
    if seq[i]==0:
        print(i+1)
        return

### FIXED CODE ###

from sys import stdin

seq = list(map(int, stdin.readline().split()))
for i in range(5):
  if seq[i]==0:
    print(i+1)
    break
print('YES' if int(input())%500<=int(input()) else 'NO')

### FIXED CODE ###

print('NO'if int(input().replace(' ',''))%4 else 'YES')
a, b, c = (int(i) for i in input().split())

if (a * c) ＜ b:
    print(c)
else:
    print(b//a)

### FIXED CODE ###

a, b, c = (int(i) for i in input().split())

if ((a * c) < b):
    print(c)
else:
    print(b//a)
from heapq import heapify, heappop, heappush
import sys

input = sys.stdin.readline

n, m = map(int, input().split())
A = list(map(int, input().split()))

BC = [tuple(map(int, input().split())) for _ in range(m)]

for b, c in BC:
    for _ in range(b):
        A.append(c)

A = list(map(lambda x: -x, A))
heapify(A)

answer = 0
for _ in range(n):
    answer += heappop(A)

print(-answer)


### FIXED CODE ###

import heapq
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
A = map(int, input().split())
A = list(map(lambda x: x*(-1), A))
heapq.heapify(A)

for _ in range(m):
    max_price = -heapq.heappop(A) // 2
    heapq.heappush(A, -max_price)

total = -sum(A)
print(total)
a,b = map(int,input().split())

n = list(map(int,input().split()))
nnn = [pow(2,i) for i in range(45)]
n.sort()
n.reverse()
kkk = len(str(bin(n[0]))) - 2
k = [[0,0] for i in range(kkk)]
nn = 1
co = 0
su = 0
for i in range(kkk):
	for j in range(a):
		if n[j] & nn > 0:
			k[i][0] += 1
		else:
			k[i][1] += 1
	nn *= 2
if nn != 1:
	nn //= 2
for i in range(kkk):
	if k[44-i][1] > k[44-i][0]:
		if su + pow(2,44-i) <= b:
			su += pow(2,44-i)

for i in range(a):
	co += su ^ n[i]
print(co)


### FIXED CODE ###

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

fm = 0
for i in range(40,0,-1):
    x = 2**(i-1)
    p = 0
    q = 0
    for j in a:
        b = x & j
        p += x ^ b
        q += b
    if q >= p:
        fm += q
    else:
        if m >= x:
            fm += p
            m -= x
        else:
            fm += q
print(fm)
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=0
i=0
s=0
while D<=X or i<N:
  D+=L[i]
  s+=1
  i+=1
print(s)

### FIXED CODE ###

S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    n,x=L()
    l=L()
    ans=1
    d=0
    for i in range(n):
       d=d+l[i]
       if d<=x:
           ans+=1
    print(ans)
    

if __name__=='__main__':
    main()
alp_count = [0]*26

while True:

    string = str(input()).lower()

    alp = [chr(ord("a")+i) for i in range(26)]

    c = 0

    for j in range(26):
        c = string.count(alp[j])
        alp_count[j] += c
        print("%s : %d"%(alp[j],c))


### FIXED CODE ###

alp_count = [0]*26



string = open(0).read()
string = string.lower()


alp = [chr(ord("a")+i) for i in range(26)]

c = 0

for j in range(26):
    c = string.count(alp[j])
    alp_count[j] += c
    print("%s : %d"%(alp[j],alp_count[j]))