Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
n,q = map(int, input().split())
s = input()
td = [input().split() for _ in range(q)]

l = 0
r = n - 1
for i in range(q-1,-1,-1):
    t,d = td[i]

    if s[l]==t and d=="L":
        l += 1
    elif l>0 and s[l-1]==t and d=="R":
        l -= 1

    if s[r]==t and d=="R":
        r -= 1
    elif r<n-1 and s[r+1]==t and d=="L":
        r += 1

print(n - l - (n-1-r))


### FIXED CODE ###

# -*- coding: utf-8 -*-
n,q = map(int, input().split())
s = input()
td = [input().split() for _ in range(q)]

def check(idx, x):
    for t,d in td:
        if idx==x:
            return True
        elif idx==n or idx==-1:
            return False

        if s[idx]==t:
            if d=="L":
                idx -= 1
            else:
                idx += 1
    return idx==x

ok = -1
ng = n
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if check(mid, -1):
        ok = mid
    else:
        ng = mid
res = ok+1

ok = n
ng = -1
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    if check(mid, n):
        ok = mid
    else:
        ng = mid
res += n-ok

print(n-res)
S = str(input())
s = list(S)
if s[0] == s[1]:
    if s[2] == s[3]:
        print("Yes")
    else:
        print("No")
else if s[0] == s[2]:
    if s[1] == s[3]:
        print("Yes")
    else:
        print("No")
else if s[0] == s[3]:
    if s[1] == s[2]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

S = str(input())
s = list(S)

if s[0] == s[1] == s[2] == s[3]:
    print("No")
elif s[0] == s[1] and s[2] == s[3]:
        print("Yes")
elif s[0] == s[2] and s[1] == s[3]:
        print("Yes")
elif s[0] == s[3] and s[1] == s[2]:
        print("Yes")
else:
        print("No")
import math
a, b = map(decimal, input().split())
b = b*1000
c = a*b
print(math.floor(c/1000))

### FIXED CODE ###

a,b = input().split()
a = int(a)
b = int(b.replace(".",""))
print(a*b//100)
# -*- coding: utf-8 -*-
def resolve():
    a, b, c = map(int, list(input()))
    print(a + b + c)


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    a, b, c = map(int, input().split())

    temp_a = a
    temp_b = b
    a = temp_b
    b = temp_a
    temp_c = c
    temp_a = a
    c = temp_a
    a = temp_c
    print(a, b, c)
resolve()
A,B,C = map(int.input().split())
print(max(A+B,B+C,C+A))

### FIXED CODE ###

listabc = sorted(list(map(int,input().split())))
print(9*listabc[2]+sum(listabc))
import fractions
    from functools import reduce
     
    n = int(input())
    a = list(map(int,input().split()))
     
    #累積GCD
    left = [0] * (n + 1)
    right = [0] * (n + 1)
    for i in range(n):
        left[i + 1] = (math.gcd(left[i],a[i]))
        right[n - i - 1] = (math.gcd(right[n - i],a[n - 1 - i]))
     
    ans = 0
    for i in range(n - 1):
        ans = max(ans,fractions.gcd(left[i],right[i + 1]))
    print(ans)

### FIXED CODE ###

import fractions
from functools import reduce

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

#累積GCD
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    #left.append(math.gcd(left[i],a[i]))
    left[i + 1] = (fractions.gcd(left[i],a[i]))
    #right.insert(0,math.gcd(right[0],a[n - 1 - i]))
    right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i]))
#print(left)
#print(right)

ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)
N = int(input())
K = int(input())

ans = 0
for i in range(N):
    x = int(input)
    ans += 2*min(x,K-x)
print(ans)


### FIXED CODE ###

N = int(input())
K = int(input())

x = input().split()

ans = 0
for i in range(N):
    ans += 2*min(int(x[i]), K-int(x[i]))
    
print(ans)
H, W = map(int, input().split())

S = ["."*W]
ans = 'Yes'
for i in range(H):
    s = input()
    S.append('.'+s+'.')

S.append('.'*W)

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == '#':
            if S[i][j+1] == '#' or S[i][j-1] == '#' or S[i+1][j] == '#' or S[i-1][j] == '#':
                continue
            else:
                ans = 'No'
                break

print(ans)


### FIXED CODE ###

H, W = map(int, input().split())

S = ["."*(W+2)]
ans = 'Yes'
for i in range(H):
    s = input()
    S.append('.'+s+'.')

S.append('.'*(W+2))

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == '#':
            if S[i][j+1] == '#' or S[i][j-1] == '#' or S[i+1][j] == '#' or S[i-1][j] == '#':
                continue
            else:
                ans = 'No'
                break

print(ans)
def main():
  X=int(input())
  for i in X:
    a=X+i
    if all(a%j!=0 for j in range(2,a)):
      print(a)
  break
main()

### FIXED CODE ###

X=int(input())
b=X**0.5
while any(X%i==0 for i in range(2,int(b)+1)):
  X+=1
else:
  print(X)
N,X = [int(i) for i in input().split()]

def get_next_burger(current_burger) :
	return "B" + current_burger + "P" + current_burger + "B"

current = "P"

for i in range(N) :
	current = get_next_burger(current)

target = current[:X]
print(target.count("P"))

### FIXED CODE ###

D = int(input())

if (D == 25) :
	print("Christmas")
elif (D == 24) :
	print("Christmas Eve")
elif (D == 23):
	print("Christmas Eve Eve")
elif (D == 22):
	print("Christmas Eve Eve Eve")
n = int(input())
s = input()

min_n = s[1:].count('E')
for i in range(1, n):
    tmp_n += s[i-1].count('W') - s[i].count('E')
    min_n = min(tmp_n, min_n)

print(min_n)

### FIXED CODE ###

n = int(input())
s = input()

min_n = s[1:].count('E')
tmp_n = min_n
for i in range(1, n):
    tmp_n += s[i-1].count('W') - s[i].count('E')
    min_n = min(tmp_n, min_n)

print(min_n)
a,b=map(int,input().split())
cnt=0
for l in range(a,b+1):
            l_i=list(str())
            if l_i[0]==l_i[-1] and l_i[1]=l_i[-2]:
                        cnt+=1
print(cnt)                        


### FIXED CODE ###

s=list(input())
t=list(input())
v=list(input())
print(s[0]+t[1]+v[2])
n, x = map(int, input().split())
l = list(map(int, input().split()))

wk = 0
for i in range(n):
    wk += l[i]
    #print(i)
    #print(l[i])
    if(wk > x):
        print(i + 1)
        exit()
print(n + 1)

### FIXED CODE ###

x,a=map(int,input().split())
if x<a:
    print(0)
else:
    print(10)
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline


import collections,sys,threading
sys.setrecursionlimit(10**9)
threading.stack_size(10**8)






########################################
def solve():
	n , m = map(int , input().split())
	dic = defaultdict(set)
	for ii in range(m):
		u,v = map(int , input().split())
		dic[u].add(v)
		dic[v].add(u)
	l = []
	visited = [0]*(n+1)
	def f(node):
		visited[node] = True
		if len(dic[node]) == 1:
			return 1
		temp = 1
		for nei in dic[node]:
			if not visited[nei]:
				temp += f(nei)
				#print("?",node, nei , temp)
		return temp
	for i in range(1,n+1):
		if not visited[i]:
			l.append(f(i))
	#print(dic)
	#print(l)
	print(max(l))


threading.Thread(target=solve).start()





### FIXED CODE ###

#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline


class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))

    def find(self, a):
        acopy = a
        while a != self.parent[a]:
            a = self.parent[a]
        while acopy != a:
            self.parent[acopy], acopy = a, self.parent[acopy]
        return a

    def union(self, a, b):
        self.parent[self.find(b)] = self.find(a)




n , m = map(int , input().split())
#dic = defaultdict(set)
uf = UnionFind(n)
for ii in range(m):
	u,v = map(int , input().split())
	u-=1
	v-=1
	uf.union(u,v)
c = [0]*n
for i in range(n):
	c[uf.find(i)] += 1
print(max(c))



'''
import collections,sys,threading
sys.setrecursionlimit(10**9)
threading.stack_size(10**8)






########################################
def solve():
	n , m = map(int , input().split())
	dic = defaultdict(set)
	for ii in range(m):
		u,v = map(int , input().split())
		dic[u].add(v)
		dic[v].add(u)
	l = []
	visited = [0]*(n+2)
	def f(node):
		visited[node] = True
		temp = 0
		for nei in dic[node]:
			if not visited[nei]:
				temp += f(nei)
				#print("?",node, nei , temp)
		return temp
	for i in range(1,n+1):
		if not visited[i]:
			l.append(f(i)+1)
	#print(dic)
	#print(l)
	print(max(l))


threading.Thread(target=solve).start()

'''
n=int(input())
a=list(map(int,input().split()))
m=max(a)
alsit=[0]*(m+1)
for i in a:
  for j in range(i,m+1,i):
    alist[j]+=1
cnt=0
for i in a:
  if alist[i]==1:
    cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
m=max(a)
alist=[0]*(m+1)
for i in a:
  for j in range(i,m+1,i):
    alist[j]+=1
cnt=0
for i in a:
  if alist[i]==1:
    cnt+=1
print(cnt)
r, g, b, n = map(int, input().split())
ans = 0
nr = n // r
ng = n // g
for i in range(nr + 1):
    for j in range(ng + 1):
      	tmp = n - i * r - j * g 
        if tmp >= 0 and tmp % b == 0:
            ans += 1
print(ans)


### FIXED CODE ###

r, g, b, n = map(int, input().split())
ans = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g == n:
            ans += 1
        elif (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % b == 0:
            ans += 1
print(ans)
import math

a, b, c, d = list(map(int,input().split(" ")))

ac_r = a % c
ad_r = a % d
lcm =  (c*d) // math.gcd(c, d)
acd_r = a % lcm
n = b - a + 1

if (ac_r == 0 and n % c == 1) or ((ac_r == 0 and n % c == 2) or (ac_r == 2 and n % c == 2)) :
    n_c = n // c + 1
else:
    n_c = n // c
    
if (ad_r == 0 and n % d == 1) or ((ad_r == 0 and n % d == 2) or (ad_r == 2 and n % d == 2)):
    n_d = n // d + 1
else:
    n_d = n // d
    
if (acd_r == 0 and n % (c*d) == 1) or ((acd_r == 0 and n % (c*d) == 2) or (acd_r == 2 and n % (c*d) == 2)):
    n_cd = n // lcm + 1
else:
    n_cd = n // lcm
    
print(n - (n_c + n_d - n_cd)) 
print(ac_r, ad_r, acd_r, n)

### FIXED CODE ###

def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)
 
def lcm(a, b):
    return a // gcd(a, b) * b

a, b, c, d = list(map(int,input().split(" ")))

n = b - a + 1
n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
n_cd = b//lcm(c,d) - (a-1)//lcm(c,d)

print(n - n_c - n_d + n_cd)
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(int(pow(P,(1/N)))+1)):
    tmp=i**N
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break:
print(ans)

### FIXED CODE ###

import math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(round(math.pow(P,(1/N)))+1)):
    tmp=math.pow(i,N)
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break
print(ans)
k,t = map(int,input().split())
A = list(map(int,input().split()))
at = max(A)
print(max(at−1−(k−at),0))

### FIXED CODE ###

k, t = map(int, input().split())
a = list(map(int, input().split()))
print(max(2*max(a)-k-1, 0))
from collections import deque
from bisect import bisect_left
n = int(input())
ans = deque([int(input())])
for i in range(n-1):
    now = int(input())
    j = bisect_left(ans,now)
    if j == 0:
        ans.insert(0,now)
    else:
        ans[j-1] = now

print(len(ans))

### FIXED CODE ###

def bisect_right(a, x, lo=0, hi=None):
    """Return the index where to insert item x in list a, assuming a is sorted.

    The return value i is such that all e in a[:i] have e <= x, and all e in
    a[i:] have e > x.  So if x already appears in the list, a.insert(x) will
    insert just after the rightmost x already there.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.
    """

    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if x < a[mid]: hi = mid
        else: lo = mid+1
    return lo

n = int(input())
f = int(input())
ans = [-f]
for i in range(n-1):
    now = -int(input())
    j = bisect_right(ans,now)
    if j == len(ans):
        ans.append(now)
    else:
        ans[j] = now

print(len(ans))
import sys
import math
f = sys.stdin
n = int(f.readline())
a = list(map(int, f.readline().split()))
a.sort()
gcd = math.gcd(a[0], a[1])
print(gcd)

### FIXED CODE ###

import sys
import fractions
import functools
f = sys.stdin
n = int(f.readline())
a = list(map(int, f.readline().split()))
gcd = functools.reduce(fractions.gcd, a)
print(gcd)
import sys
from sympy import divisors
from collections import Counter


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a_list = list(map(int, input().split()))
    # キーに要素、値に出現回数を持つカウンタ
    a_counter = Counter(a_list)
    ans = 0
    for a in a_list:
        # aの約数の集合
        divs = divisors(a)
        for divisor in divs:
            if a_counter[divisor] > 0:
                if divisor == a and a_counter[divisor] == 1:
                    continue
                break
        else:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import Counter


def main():
    input = sys.stdin.buffer.readline
    _ = input()
    a_list = list(map(int, input().split()))
    res_set = set(a_list)
    # キーに要素、値に出現回数を持つカウンタ
    a_counter = Counter(a_list)
    for e in a_counter.items():  # e:(整数，出現回数)
        if e[1] == 1:
            for i in range(e[0] * 2, 10**6 + 1, e[0]):  # その整数を含まない倍数
                res_set.discard(i)
        else:
            for i in range(e[0], 2 * 10**6 + 1, e[0]):  # その整数を含む倍数
                res_set.discard(i)
    print(len(res_set))


if __name__ == '__main__':
    main()
a, b, m = map(int, input().split())
a1 = list(map(int, input().split()))
b1 = list(map(int, input().split()))

disc = [list(map(int, input().split())) for i in range(m)]
import numpy as np

b2 = np.array(b1)
a2 = np.array(a1)
a2 = a2.reshape(a,1)

from collections import deque
ans = []
ans = deque(ans)

for i in range(m):
    ans.append( a1[disc[i][0]-1] + b1[disc[i][1]-1] - disc[i][2] )

ans = list(ans)
print(min( min(ans), np.min(a2+b2) ))


### FIXED CODE ###

a, b, m = map(int, input().split())
a1 = list(map(int, input().split()))
b1 = list(map(int, input().split()))

disc = [list(map(int, input().split())) for i in range(m)]
import numpy as np


from collections import deque
ans = []

ans = deque(ans)

for i in range(m):
    ans.append( a1[disc[i][0]-1] + b1[disc[i][1]-1] - disc[i][2] )

ans = list(ans)

print(min( min(ans), min(a1)+min(b1) ))
a, b, k = int(i) for i in input().split()
takahashi = a - k
aoki = b + takahashi if takahashi < 0 else b
print(f"{max(takahashi, 0)} {max(aoki, 0)}")


### FIXED CODE ###

a, b, k = (int(i) for i in input().split())
takahashi = a - k
aoki = b + takahashi if takahashi < 0 else b
print("{} {}".format(max(takahashi, 0), max(aoki, 0)))
import itertools
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = 0
list1 = [] #あって    眺めがいい
list2 = [] #ない     道が通ってる
list3 = [x for x in range(1,n+1)]
list4 = []
for i in range(m):
    a,b = map(int,input().split())
    list2.append(a)
    list2.append(b)
    if h[a-1] > h[b-1]:
        list1.append(a)
    else:
        list1.append(b)
list1 = list(set(list1))
list2 = list(set(list2))
for i in range(n):
    if list2[i] not in list3:
        list4.append(list2[i])

print(len(list1)+len(list4))

### FIXED CODE ###

N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))
O = [0] + [1] * N
for _ in range(M):
    A, B = map(int, input().split())
    if H[A] <= H[B]:
        O[A] = 0
    if H[A] >= H[B]:
        O[B] = 0
print(sum(O))
while True:
    m, f, r = [int(i) for i in input().solit()]

    if m == f == r == -1:
        break

    elif m == -1 or f == -1:
        print("F")

    elif m + f >= 80:
        print("A")

    elif 65 <= m + f < 80:
        print("B")

    elif 50 <= m + f < 65:
        print("C")

    elif 30 <= m + f < 50:
        if r > 50:
            print("C")
        else:
            print("D")

    else
        print("F")

### FIXED CODE ###

while True:
    m, f, r = [int(i) for i in input().split()]

    if m == f == r == -1:
        break

    elif m == -1 or f == -1:
        print("F")

    elif m + f >= 80:
        print("A")

    elif 65 <= m + f < 80:
        print("B")

    elif 50 <= m + f < 65:
        print("C")

    elif 30 <= m + f < 50:
        if r >= 50:
            print("C")
        else:
            print("D")

    elif m + f < 30:
        print("F")

    elif m + f < 30:
        print("F")
import sys
from math import cos, radians, pi, sqrt
import numpy as np
import pandas as pd

inputs = input()
inputs = inputs.split('\n')

N = int(inputs[0].split()[0])
M = int(inputs[0].split()[1])

i = 1
dic = {}
for i in range(1, M+1):
#	print("探索%d回目" % i)
	param = inputs[i].split()
	A = param[0]
	B = param[1]

	if A in dic.keys():
		dic[A].append(B)
	else:
		dic[A] = []
		dic[A].append(B)

	if B in dic.keys():
		dic[B].append(A)
	else:
		dic[B] = []
		dic[B].append(A)
	
depth = {'1': 0}
que = dic['1']
count=1

while not que == []:
	next_que = []
	for room in que:
		if room in depth.keys():
			continue

		depth[room] = count
		for next_room in dic[str(room)]:
			if not next_room in next_que:
				next_que.append(next_room)
	count += 1
	que = next_que

dist = {}
for i in range(2, N+1):
	for room, dep in depth.items():
		if depth[str(i)]-1 == dep:
			dist[str(i)] = room
			break

print("yes")
for opt in dist.items():
	print(opt[1])


### FIXED CODE ###

n,m = map(int,input().split())
visited = [-1 for _ in range(n+1)]
visited[1] = 0
will = []
root = [[] for _ in range(n+1)] 
for i in range(m):
    a,b = map(int,input().split())
    root[a].append(b)
    root[b].append(a)

will.append(1)

while will:
    visit = will.pop(0)
    for i in root[visit]:
        if visited[i] != -1:
            continue
        will.append(i)
        visited[i] = visit

if visited[1:] == -1:
    print('No')
else:
    print('Yes')
    for i in range(2,len(visited)):
        print(visited[i])
n, k = map(int, input().split())

x = n % k
print(min(x, abs(k-x))

### FIXED CODE ###

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

x = n % k
print(min(x, abs(k-x)))
x=str(input())
  if x=="A":
    print("T")
  elif x=="T":
    print("A")
  elif x=="C":
    print("G")
  elif x=="G":
    print("C")


### FIXED CODE ###

x=input()

if x=="A":
  print("T")
elif x=="T":
  print("A")
elif x=="C":
  print("G")
else:
  print("C")
def calc(prepoint, nextpoint):
    return abs(nextpoint[0]-prepoint[0]) + abs(nextpoint[1]-prepoint[1])

def search(i,A):
    for h in range(H):
        if L in A[h]:
            return (h,A[h].index(L))

H,W,D = map(int,input().split())
A = [list(map(int, input().split())) for i in range(H)]
Q = int(input())
L_R_List = [list(map(int, input().split())) for i in range(Q)]

temp = [(0,0) for i in range(H*W)]
for L_R in L_R_List:
    L = L_R[0]
    R = L_R[1]
    ans = 0
    if temp[L] == (0,0):
        temp[L] = search(L,A)
        prepoint = temp[L]
    else:
        prepoint = temp[L]
    while(L != R):
        L += D
        if temp[L] == (0,0):
            temp[L] = search(L,A)
            nextpoint = temp[L]
        else:
            nextpoint = temp[L]
        ans += calc(prepoint, nextpoint)
        prepoint = nextpoint
    print(ans)


### FIXED CODE ###

def calc(prepoint, nextpoint):
    return abs(nextpoint[0]-prepoint[0]) + abs(nextpoint[1]-prepoint[1])

def main():
    H,W,D = map(int,input().split())
    index  = [(0,0) for i in range(H*W+1)]
    A = []
    for i in range(H):
        temp = list(map(int, input().split()))
        for t in temp:
            index[t] = (i,temp.index(t))
        A.append(temp)
    Q = int(input())
    L_R_List = [list(map(int, input().split())) for i in range(Q)]

    dp = [0 for i in range(H*W+1)]
    for i in range(D, H*W+1):
        dp[i] = dp[i-D] + calc(index[i], index[i-D])
    for L_R in L_R_List:
        L = L_R[0]
        R = L_R[1]
        print(dp[R]-dp[L])

if __name__ == '__main__':
    main()
import math
N = int(input())
AAA = [int(i) for i in input().split()]
BBB = [0]
for a in AAA:
    BBB.append(a+BBB[-1])
ans=[]
#print(BBB)
BBB=sorted(BBB)
#print(BBB)
prev = math.inf
buff=BBB[0]
ans=[]
for i,b in enumerate(BBB):
    #print(b,prev,buff)
    if b==prev:
        buff+=1
    else:
        if buff>=2:
            #print("append!")
            ans.append(buff)
        buff=1
        prev=b
if buff!=1:
    ans.append(buff)
#print(ans)
print(sum([(i-1)*i//2 for i in ans]))

### FIXED CODE ###

N = int(input())
AAA = [int(i) for i in input().split()]
BBB = [0]
for a in AAA:
    BBB.append(a+BBB[-1])
ans=[]
#print(BBB)
BBB=sorted(BBB)
#print(BBB)
prev = float("inf")
buff=BBB[0]
ans=[]
for i,b in enumerate(BBB):
    #print(b,prev,buff)
    if b==prev:
        buff+=1
    else:
        if buff>=2:
            #print("append!")
            ans.append(buff)
        buff=1
        prev=b
if buff!=1:
    ans.append(buff)
#print(ans)
print(sum([(i-1)*i//2 for i in ans]))
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            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 size(self, x):
        return -self.parents[self.find(x)]

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

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

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
List=[i for i in range(10**5+1)]
Uf=UnionFind(10**5)
for i in range(Q):
    B,C=map(int,input().split())
    List[B]=C
    Uf.union(B,C)
    for i in Uf.members(B):
        index=i
        while index!=List[index]:
            index=List[index]
            if index==i:
                break
            # print(index)
            # print(List)
        List[i]=index
    ChangedA=[List[a] for a in A]
    print(sum(ChangedA))

### FIXED CODE ###

import numpy as np
N=int(input())
A=list(map(int,input().split()))
SUM=sum(A)
Q=int(input())
List=np.array([0 for _ in range(10**5+1)])
for a in A:
    List[a]+=1
for q in range(Q):
    B,C=map(int,input().split())
    SUM-=B*List[B]
    SUM+=C*List[B]
    List[C]+=List[B]
    List[B]=0
    print(SUM)
import math
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input())
t_list=[]
for i in range(n):
    math.fabs(t-h[i]*0.006-a)
print(min(t_list))

### FIXED CODE ###

import math
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
before=math.fabs(t-h[0]*0.006-a)
num=1
for i in range(n-1):
  diff=before-math.fabs(t-h[i+1]*0.006-a)
  if diff>0:
    before=math.fabs(t-h[i+1]*0.006-a)
    num=i+2
print(num)