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

n = int(input())
s = input()
w = [s[:i+1].count("W") for i in range(n)]
e = [i+1-w[i] for i in range(n)]
ans = e[-1]
for i in range(1,n):
  ans = min(ans, w[i-1]+e[-1]-e[i])
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
w = []
c = 0
for i in range(n):
  if s[i] == "W":
    c += 1
  w.append(c)
e = [i+1-w[i] for i in range(n)]
ans = e[-1]
for i in range(1,n):
  ans = min(ans, w[i-1]+e[-1]-e[i])
print(ans)
### BUGGY CODE ###

import sys,collections as cl,bisect as bs,heapq as hq
sys.setrecursionlimit(100000)
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def search(a,n):
    se = dict()
    data = []
    for i in range(0,len(a)-n+1):
        kkk = a[i:i+n]
        kkk = "".join(kkk)
        if In(kkk,data):
            for j in range(len(se[kkk])):
                if se[kkk][j] <= i-n:
                    return True
            else:
                se[kkk].append(i)
        else:
            bs.insort(data,kkk)
            se[kkk] = [i]
    return False
def solver():
    n = onem()

    s = list(input())
    l = 0
    r = n//2
    for i in range(n):
        mid = -(-(l+r)//2)
        ans = search(s,mid)
        if l == mid:
            break
        if ans:
            l = mid
        else:
            r = mid-1
    print(l)




solver()




### FIXED CODE ###

import sys,collections as cl,bisect as bs,heapq as hq
input = sys.stdin.readline
sys.setrecursionlimit(100000)
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def search(a,n):
    se = dict()
    data = []
    for i in range(0,len(a)-n+1):
        kkk = a[i:i+n]
        kkk = "".join(kkk)
        if In(kkk,data):
            if se[kkk] <= i-n:
                    return True
        else:
            bs.insort(data,kkk)
            se[kkk] = i
    return False
def solver():
    n = onem()

    s = list(input())
    l = 0
    r = n//2
    for i in range(n):
        mid = -(-(l+r)//2)
        ans = search(s,mid)
        if l == mid:
            break
        if ans:
            l = mid
        else:
            r = mid-1
    print(l)



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

import heapq
N, M, init_silver = map(int, input().split())
MAX_COST = 2500
init_silver = min(init_silver, MAX_COST)

G = [[] for _ in range(N)]
for i in range(M):
    u, v, silver_cost, time_cost = map(int, input().split())
    u, v = u - 1, v - 1
    G[u].append([v, silver_cost, time_cost])
    G[v].append([u, silver_cost, time_cost])

change_rate, change_cost = [], []
for i in range(N):
    rate, cost = map(int, input().split())
    change_rate.append(rate)
    change_cost.append(cost)


# dp[i][silver] := 頂点iにいて銀貨をsilver枚持っているような状況を作るために必要な最小時間
dp = [[float('inf')] * (MAX_COST + 1) for _ in range(N)]
dp[0][init_silver] = 0

# 優先度付きキュー: (time, node, silver)
hq = [(0, 0, init_silver)]
while hq:
    time, node, silver = heapq.heappop(hq)

    self_loop_silver = min(silver + change_rate[node], MAX_COST)
    self_loop_cost = time + change_cost[node]
    if self_loop_cost < dp[node][self_loop_silver]:
        dp[node][self_loop_silver] = self_loop_cost
        heapq.heappush(hq, (time + change_cost[node], node, self_loop_silver))

    for to, silver_cost, time_cost in G[node]:
        remain_silver = min(silver - silver_cost, MAX_COST)
        if remain_silver < 0:
            continue

        dp_next_value = time + time_cost
        if dp[to][remain_silver] < dp_next_value:
            continue

        dp[to][remain_silver] = dp_next_value
        heapq.heappush(hq, (dp_next_value, to, remain_silver))

print(*[min(d) for d in dp[1:]], sep="\n")


### FIXED CODE ###

import heapq
N, M, init_silver = map(int, input().split())
MAX_COST = 2500
init_silver = min(init_silver, MAX_COST)

G = [[] for _ in range(N)]
for i in range(M):
    u, v, silver_cost, time_cost = map(int, input().split())
    u, v = u - 1, v - 1
    G[u].append([v, silver_cost, time_cost])
    G[v].append([u, silver_cost, time_cost])

change_rate, change_cost = [], []
for i in range(N):
    rate, cost = map(int, input().split())
    change_rate.append(rate)
    change_cost.append(cost)


# dp[i][silver] := 頂点iにいて銀貨をsilver枚持っているような状況を作るために必要な最小時間
dp = [[float('inf')] * (MAX_COST + 1) for _ in range(N)]
dp[0][init_silver] = 0

# 優先度付きキュー: (time, node, silver)
hq = [(0, 0, init_silver)]
while hq:
    time, node, silver = heapq.heappop(hq)

    self_loop_silver = min(silver + change_rate[node], MAX_COST)
    self_loop_cost = time + change_cost[node]
    if self_loop_cost < dp[node][self_loop_silver]:
        dp[node][self_loop_silver] = self_loop_cost
        heapq.heappush(hq, (time + change_cost[node], node, self_loop_silver))

    for to, silver_cost, time_cost in G[node]:
        remain_silver = min(silver - silver_cost, MAX_COST)
        if remain_silver < 0:
            continue

        dp_next_value = time + time_cost
        if dp[to][remain_silver] <= dp_next_value:
            continue

        dp[to][remain_silver] = dp_next_value
        heapq.heappush(hq, (dp_next_value, to, remain_silver))

print(*[min(d) for d in dp[1:]], sep="\n")
### BUGGY CODE ###

n, m, k = input().split()
a = input().split()
b = input().split()

n = int(n)
m = int(m)
k = int(k)
a = list(map(int, a))
b = list(map(int, b))

ans = 0
temp_a = {}
temp_b = {}

for i_a in range(n+1):
  if sum(a[0:i_a]) > k:
    break
  temp_a[i_a] = sum(a[0:i_a])
for i_b in range(m+1):
  if sum(b[0:i_b]) > k:
    break
  temp_b[i_b] = sum(b[0:i_b])
  
temp_a = sorted(temp_a.items(), key=lambda x:x[1], reverse=True)
temp_b = sorted(temp_b.items(), key=lambda x:x[1], reverse=True)
ans = {}

for item_a in temp_a:
  for item_b in temp_b:
    if item_a[1] + item_b[1] > k:
      continue
    else:
      ans[len(ans)] = item_a[0] + item_b[0]
      break

ans = max(ans.values())
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 a[i] + b[j] > k:
    j -= 1
  ans = max(ans, i+j)

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

from functools import reduce
import fractions

N = int(input())
A = [int(i) for i in input().split()]


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


ans = 0
for i in range(N):
    B = A[:i]+A[i+1:]
    ans = max(ans, gcd(*B))
print(ans)


### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000)

import fractions
from functools import reduce

N=int(input())
A=[int(i) for i in input().split()]

def mygcd(a,b):
    if a==0:
        return b
    elif b==0:
        return a
    else:
        return fractions.gcd(a,b)

L=[0]*N
for i in range(1,N):
    L[i]=mygcd(L[i-1],A[i-1])

R=[0]*N
for i in range(N-2,-1,-1):
    R[i]=mygcd(R[i+1],A[i+1])

ans=1
for i in range(N):
    c=mygcd(L[i],R[i])
    ans=max(ans,c)

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

H, W = map(int, input().split())
S = [input() for _ in range(H)]

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        else:
            cnt = 1 # 光の数 自分も含む

            flg = True
            k = 1
            while flg:
                if i-k < 0:
                    flg = False
                    break
                else:
                    if S[i-k][j] == '#':
                        flg = False
                        break
                    else:
                        cnt += 1
                k += 1

            flg = True
            k = 1
            while flg:
                if j-k < 0:
                    flg = False
                    break
                else:
                    if S[i][j-k] == '#':
                        flg = False
                        break
                    else:
                        cnt += 1
                k += 1

            flg = True
            k = 1
            while flg:
                if i+k >= H:
                    flg = False
                    break
                else:
                    if S[i+k][j] == '#':
                        flg = False
                        break
                    else:
                        cnt += 1
                k += 1

            flg = True
            k = 1
            while flg:
                if j+k >= W:
                    flg = False
                    break
                else:
                    if S[i][j+k] == '#':
                        flg = False
                        break
                    else:
                        cnt += 1
                k += 1

            ans = max(cnt, ans)

# print(S)
print(ans)


### FIXED CODE ###

import numpy as np
H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'
us = np.zeros((H,W), dtype=int)    # .の連続数を格納用
ds = np.zeros((H,W), dtype=int)    # .の連続数を格納用
ls = np.zeros((H,W), dtype=int)    # .の連続数を格納用
rs = np.zeros((H,W), dtype=int)    # .の連続数を格納用

for h in range(1,H):
    us[h, :] = (us[h-1, :] + 1) * S[h-1, :]
for h in range(H-2, -1, -1):
    ds[h, :] = (ds[h+1, :] + 1) * S[h+1, :]
for w in range(1,W):
    ls[:, w] = (ls[:, w-1] + 1) * S[:, w-1]
for w in range(W-2, -1, -1):
    rs[:, w] = (rs[:, w+1] + 1) * S[:, w+1]

ans = ((us + ds + ls + rs)*S).max() + 1
print(ans)
### BUGGY CODE ###

import math
import sys
from functools import lru_cache
#from scipy.special import comb
from operator import mul
from functools import reduce

n,a,b=map(int,input().split())
'''
def memoize(f): #メモ化関数
    table = {}
    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func

@memoize
def memFrac(n):
    if ( n==0 ):
        return 1
    else:
        return n*memFrac(n-1)

def perm(n,r):
    return memFrac(n) // (memFrac(n - r)*memFrac(r))

sys.setrecursionlimit(1000000007)
@lru_cache(maxsize=1000)
def frac(n):
    if n<2:
        return n
    else:
        return n*frac(n-1)

def perm(n,r):
    return frac(n) // (frac(n - r)*frac(r))

a1 = comb(n, a, exact=True)
b1 = comb(n, b, exact=True)

'''
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
a1=cmb(n,a)
b1=cmb(n,b)

print(int(pow(2,n)-a1-b1-1)%1000000009)

### FIXED CODE ###

#pが素数の時、p未満の数の積xについてx^(p-1)=1(mod p) <=> x^(p-2)=1/x(mod p) (オイラの小定理)
#ここでpは素数なので、p以下の数a,b,nにおいてcmb(n,a)≡n!/((n-a)!*a!)≡((n-a+1)*…*n)/(a!)≡((n-a+1)*…*n)(a!)^(p-2) (mod p)
#あとは((n-a+1)*…*n)(a!)^(p-2) (mod p)を繰り返し2乗法でO(log(p))で求められる…らしいが普通にpow(n,r,mod)つよそう

def modcmb(n,r,mod):
    upper=1
    for i in range(n-r+1,n+1,1):
        upper=(upper*i)%mod
    rfrac=1
    for i in range(1,r+1,1):
        rfrac=(rfrac*i)%mod
    pwrfrac=pow(rfrac,mod-2,mod)
    return (upper*pwrfrac)%mod

n,a,b=map(int,input().split())
p = 10 ** 9 + 7

print((pow(2,n,p)-1-modcmb(n,a,p)-modcmb(n,b,p))%p)
### BUGGY CODE ###

import sys
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7
N=int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]

dp = np.zeros(1<<N, dtype=np.int64)
dp[0] = 1

for A_row in A:
    prev = dp.copy()
    dp = np.zeros_like(prev)
    for n,a in enumerate(A_row):
        if a == 0:
            continue
        x = 1 << n
        dp[x:] += prev[:-x]
    dp %= MOD

answer = dp[-1]
print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7
N = int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]

bit_count = [0]
for _ in range(N):
    bit_count += [x+1 for x in bit_count]
    
dp = [0] * (1<<N)
dp[0] = 1

for i in range((1<<N)-1):
    k = bit_count[i]
    for c in range(N):
        if A[k][c]:
            dp[(1<<c)^i] += dp[i]

answer = dp[-1] % MOD
print(answer)
### BUGGY CODE ###

import sys

N=int(input())
amat=[[-1]]
for i in range(N):
  alist=list(map(int,input().split()))
  amat.append(list(reversed(alist)))
  
#print(amat)
answer=0
matched_flag=[False]*(N+1)
while(True):  
  answer+=1
  matched_flag=[False]*(N+1)
  unchanged=True
  
  for i in range(1,N+1):
    if len(amat[i]) == 0 or matched_flag[i]:
      continue
      
    ai_next = amat[i][-1]
    if amat[ai_next][-1]==i and not matched_flag[ai_next]:
      #print(i,ai_next,answer)
      amat[i].pop()
      amat[ai_next].pop()
      matched_flag[i]=True
      matched_flag[ai_next]=True
      unchanged=False
  
  if unchanged:
    print(-1)
    sys.exit()
  else:
    maxlist=-1
    for i in range(1,N+1):
      maxlist=max(maxlist,len(amat[i]))
    if maxlist==0:
      print(answer)
      sys.exit()


### FIXED CODE ###

import sys

N=int(input())
amat=[[-1]]
for i in range(N):
  alist=list(map(int,input().split()))
  amat.append(list(reversed(alist)))
  
#print(amat)
answer=0
matched_flag=[False]*(N+1)
for answer in range(1,N**3):
  if N>900 and answer>3000:
    print(N*(N-1)//2)
    sys.exit()
  
  matched_flag=[False]*(N+1)
  unchanged=True
  
  for i in range(1,N+1):
    if matched_flag[i] or len(amat[i]) == 0:
      continue
      
    ai_next = amat[i][-1]
    if amat[ai_next][-1]==i and not matched_flag[ai_next]:
      #print(i,ai_next,answer)
      matched_flag[amat[i].pop()]=True
      matched_flag[amat[ai_next].pop()]=True
      unchanged=False
  
  if unchanged:
    print(-1)
    sys.exit()
  else:
    for i in range(1,N+1):
      if len(amat[i])>0:
        break
    else:
      print(answer)
      sys.exit()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
H,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
B = [list(map(int,input().split())) for _ in range(H)]
D = [[abs(A[h][w]-B[h][w]) for w in range(W)] for h in range(H)]
dp = [[set() for _ in range(W)] for _ in range(H)]
dp[0][0].add(D[0][0])
for h in range(H):
    for w in range(W):
        if 0 < h:
            for v in dp[h-1][w]:
                v1 = v+D[h][w]
                v2 = v-D[h][w] if v>=D[h][w] else -v+D[h][w]
                dp[h][w].add(v1)
                dp[h][w].add(v2)
        if 0 < w:
            for v in dp[h][w-1]:
                v1 = v+D[h][w]
                v2 = v-D[h][w] if v>=D[h][w] else -v+D[h][w]
                dp[h][w].add(v1)
                dp[h][w].add(v2)
                
ans = min(dp[H-1][W-1])
print(ans)

### FIXED CODE ###

H,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
B = [list(map(int,input().split())) for _ in range(H)]
D = [[abs(A[h][w]-B[h][w]) for w in range(W)] for h in range(H)]
def cal():
    dp1 = [set() for _ in range(W)]
    dp2 = [set() for _ in range(W)]
    for h in range(H):
        for w in range(W):
            d = D[h][w]
            if h==0 and w==0:
                dp2[0].add(d)
            for v in dp1[w]:
                v1 = v+d
                v2 = v-d if v>=d else -v+d
                dp2[w].add(v1)
                dp2[w].add(v2)
            if 0 < w:
                for v in dp2[w-1]:
                    v1 = v+d
                    v2 = v-d if v>=d else -v+d
                    dp2[w].add(v1)
                    dp2[w].add(v2)
        dp1 = dp2
        dp2 = [set() for _ in range(W)]
    return min(dp1[W-1])
ans = cal()
print(ans)
### BUGGY CODE ###

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

memo = [0] * N
memo[0] = 1
for i in range(1, N):
    if P[i] > P[i-1]:
        memo[i] = 0
    elif P[i] == P[i-1]:
        memo[i] = memo[i-1]
    else:
        if P[i] <= min(P[0:i]):
            memo[i] = 1
        else:
            memo[i] = 0
print(sum(memo))


### FIXED CODE ###

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

memo = [0] * N
memo[0] = 1
minn = P[0]
for i in range(1, N):
    if P[i] <= minn:
        memo[i] = 1
    else:
        memo[i] = 0
    minn = min(minn, P[i])
print(sum(memo))
### BUGGY CODE ###

n = int(input())
a = [int(_) for _ in input().split()]
const = 10**9 + 7

ans = 0

zero = [0] * 60
one = [0] * 60

for i in range(n):
    for j in range(60):
        if a[i] >> j & 1:
            one[j] += 1
        else:
            zero[j] += 1

ans = 0

for i in range(60):
    ans += one[i] * zero[i] * 2**i
    ans %= const

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
a = tuple(map(int,input().split()))
const = 10**9 + 7

ans = 0

zero = [0] * 60
one = [0] * 60

for i in range(60):
    for j in range(n):
        if a[j] >> i & 1:
            one[i] += 1
        else:
            zero[i] += 1

ans = 0

for i in range(60):
    ans += one[i] * zero[i] * 2**i
    ans %= const

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

# -*- coding: utf-8 -*-
import numpy as np
import re
pattern = 'AC'
n, q = map(int, raw_input().split())
s = raw_input()

x = [raw_input() for i in range(q)]

result = re.finditer(pattern, s)

ac = np.zeros(len(s))
for match in result:
    ac[match.span()[0]] = 1

#print ac



for d in x:
    r = d.split(' ')
    start = int(r[0])-1
    end = int(r[1])
    wa = sum(ac[start:end])
    if ac[end-1]==1: wa = wa-1
    print int(wa)


### FIXED CODE ###

#!/usr/bin/env python3
N, Q = map(int, input().split())
S = input()
LR = []
for i in range(Q):
    l, r = map(int, input().split())
    LR.append([l,r])

A = [0]

cnt = 0
for i in range(1, len(S)):
    if S[i-1:i+1] == 'AC':
        cnt += 1
    A.append(cnt)

for l, r in LR:
    print(A[r-1] - A[l-1])
### BUGGY CODE ###

import itertools

n, m ,x = map(int, input().split())

# l = list(range(0, n))
# print(l)

l = []
for i in range(n):
    l.append(list(map(int, input().split())))
    
# print(l)

min_value = -1
for v in itertools.permutations(l):
    lll = [0] * (m + 1)
    for ll in v:
        # print(ll)
        for i in range(len(ll)):
            lll[i] += ll[i]
        # print(lll)
        
        flag = True
        for i in range(len(lll)):
            if i == 0:
                continue
            if lll[i] < x:
                flag = False
        if flag == True:
            # print(lll)
            
            if min_value == -1:
                min_value = lll[0]
            elif min_value > lll[0]:
                min_value = lll[0]
                
            break
        
print(min_value)

### FIXED CODE ###

import itertools
import numpy as np

n, m ,x = map(int, input().split())

# l = list(range(0, n))
# print(l)

ca_list = []
for _ in range(n):
    ca_list.append(list(map(int, input().split())))

l = [True, False]
    
# print(l)

value_list = []
for is_buy_list in itertools.product(l, repeat=n):
    sum_l = np.array([0] * (m + 1))
    for i in range(n):
        # print(ll[i])
        if is_buy_list[i]:
            sum_l += np.array(ca_list[i])
            # print(sum_l)

    # print(min(sum_l[1:]))
    if min(sum_l[1:]) >= x:
        # print(sum_l[0])
        value_list.append(sum_l[0])
# print(min(value_list))

if len(value_list) > 0:
    print(min(value_list))
else:
    print(-1)
### BUGGY CODE ###

import copy
import sys
import math

def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    B = [0] * n

    # k_max = 1 + math.ceil(math.log10(n))

    for i in range(min(k, 41)):
        for j in range(n):
            l = max(0, j-A[j]) #座標iの電球が照らす範囲の左端
            r = min(n-1, j+A[j]) #座標iの電球が照らす範囲の右端
            B[l] += 1
            if (r+1 < n):
                B[r+1] -= 1 # 後ほど累積和にしたときに、照らす範囲の右端より外には影響が及ばないようにあらかじめ1引いておく

        for j in range(n-1):
            B[j+1] += B[j]

        A = copy.deepcopy(B)
        B = [0] * n

    print(*A)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy
import sys
import math

def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    B = [0] * n

    # k_max = 1 + math.ceil(math.log10(n))

    for i in range(min(k, 41)):
        for j in range(n):
            l = max(0, j-A[j]) #座標iの電球が照らす範囲の左端
            r = min(n-1, j+A[j]) #座標iの電球が照らす範囲の右端
            B[l] += 1
            if (r+1 < n):
                B[r+1] -= 1 # 後ほど累積和にしたときに、照らす範囲の右端より外には影響が及ばないようにあらかじめ1引いておく

        for j in range(n-1):
            B[j+1] += B[j]

        A = copy.deepcopy(B)
        B = [0] * n

    print(*A)

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

N, M = input().split()
N = int(N)
M = int(M)
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), str(liin[1])])
#print(N, M, li)

ans = [0, 0]
done = []
miss = {}

for i in range(M):
  if li[i][1] == "AC":
    if li[i][0] in done:
      pass
    else:
      ans[0] += 1
      done.append(li[i][0])
      if li[i][0] in miss.keys():
        ans[1] += miss[li[i][0]]
  else:
    if li[i][0] in done:
      pass
    else:
      if li[i][0] in miss.keys():
        miss[li[i][0]] += 1
      else:
        miss[li[i][0]] = 1
print(ans[0],ans[1])

### FIXED CODE ###

N, M = map(int, input().split())
li = []
for i in range(M):
  liin = input().split()
  li.append([int(liin[0]), liin[1]])

ans1, ans2 = 0, 0
done = set([0])
miss = {}

for i in range(M):
  if li[i][0] in done:
    continue
  if li[i][1] == "AC":
    ans1 += 1
    done.add(li[i][0])
    if li[i][0] in miss:
      ans2 += miss[li[i][0]]
      del miss[li[i][0]]
  else: # "WA"
    if li[i][0] in miss:
      miss[li[i][0]] += 1
    else:
      miss[li[i][0]] = 1

print(ans1,ans2)
### BUGGY CODE ###

import numpy as np
N,K,Q=map(int,input().split())
A=[]
for i in range(Q):
    a=int(input())
    A.append(a)

P=[K]*N
P1=np.array(P)
for i in A:
    P1=P1-1
    P1[i-1]=P1[i-1]+1
for i in range(len(P1)):
    if P1[i]>0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

import numpy as np
N,K,Q=map(int,input().split())
A=[0]*N
P=[K-Q]*N
for i in range(Q):
    a=int(input())
    A[a-1]=A[a-1]+1
A=np.array(A)
P=np.array(P)
for i in range(N):
    if A[i]+P[i]>0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
r=[0]*(n-1)
t=[0]*(n)
for i in range(1,n):
  r[i-1]=i-l[i]
for i in range(n):
  t[i]=i+l[i]
rx=sorted(r)
for i in range(n-1):
  r[i]=[r[i],i]
r.sort()
ans=0
import bisect
for i in range(n):
  le=bisect.bisect_left(rx,t[i])
  ri=bisect.bisect_right(rx,t[i])
  for j in range(ri-le):
    if i<r[le+j][1]:
      ans+=1
    else:break
print(ans)  

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
r=[0]*(n-1)
t=[0]*(n)
dr={}
dt={l[0]:[0]}
for i in range(1,n):
  x=i-l[i]
  y=i+l[i]
  if x in dr:
    dr[x].append(i)
  else:
    dr[x]=[i]
  if y in dt:
    dt[y].append(i)
  else:
    dt[y]=[i]
ans=0
for x in dr.keys():
  if x>0 and x in dt:
    y=dr[x]
    z=dt[x]
    ans+=len(z)*len(y)
print(ans)
### BUGGY CODE ###

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

for i in range(N):
    print(A.index(i+1)+1)

### FIXED CODE ###

import numpy as np
N=int(input())
A=list(map(int,input().split()))
A=np.array(A)
x=np.argsort(A)
for i in x:
    print(i+1)
### BUGGY CODE ###

import re

a = input()
a = re.split(" ",a)

b = input()
b = re.split(" ",b)
b = list(map(int,b))
c = set(b)
c = list(map(int,c))
if((len(b) <= int(a[1])) or (len(c) <= len(a[1]))):
    print(0)
else:
    save = []
    for i in range(len(c)):
        x = b.count(c[i])
        save.append(int(x))
    save.sort()
    y = len(c)-int(a[1])
    ans = 0
    for i in range(int(y)):
        ans += int(save[i])
    print(ans)

### FIXED CODE ###

import re
import collections

a = input()
a = re.split(" ",a)
b = input()
b = re.split(" ",b)

c = collections.Counter(b)

c = sorted(c.items(), key=lambda x: x[1])
ans = 0
for i in range(len(c)-int(a[1])):
    ans += c[i][1]
print(ans)