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

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

S = input()
l =[0 for i in range(Q)]
r = [0 for i in range(Q)]
for i in range(Q):
    l[i], r[i] = map(int, input().split())

total = 0
for i in range(N):
    total = S.count("AC")

left = [0 for i in range(N)]
right = [0 for i in range(N)]
if S[0:2] == "AC":
    left[1] = 1
if S[N-2:N] == "AC":
    right[N-2] = 1
for i in range(2,N):
    if S[i-1:i+1] == "AC":
        left[i] = left[i-2]+1
    else:
        left[i] = left[i-1]

for i in range(N-3,-1,-1):
    if S[i:i+2] == "AC":
        right[i] = right[i+2]+1
    else:
        right[i] = right[i+1]

left.insert(0,0)
left.append(0)
right.insert(0,0)
right.append(0)

for i in range(Q):
    res = total - (left[l[i]-1] + right[r[i]+1])
    if l[i] >= 2 and S[l[i]-2] == "A" and S[l[i]-1] == "C":
        res -= 1
    if r[i] <= N-1 and S[r[i]-1] == "A" and S[r[i]] == "C":
        res -= 1
    print(res)

### FIXED CODE ###

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

S = input()
l =[0] * Q
r = [0] * Q
for i in range(Q):
    l[i], r[i] = map(int, input().split())

left = [0] * N
if S[0:2] == "AC":
    left[1] = 1
for i in range(2,N):
    if S[i-1:i+1] == "AC":
        left[i] = left[i-2]+1
    else:
        left[i] = left[i-1]

for i in range(Q):
    if (l[i] == 1):
        res = left[r[i]-1]
    else:
        res = left[r[i]-1] - left[l[i]-2]
    if l[i] >= 2 and S[l[i]-1] == "C" and S[l[i]-2] == "A":
        res -= 1
    print(res)
### BUGGY CODE ###

import fractions
from functools import reduce


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
N = int(input())
Alist = list(map(int, input().split()))
l = 1
ans = 0
for a in Alist:
    l = lcm(l, a)
for a in Alist:
    ans += l//a
print(ans%(10**9+7))


### FIXED CODE ###

import sys
input = sys.stdin.readline
N = map(int, input().split())
Alist = list(map(int, input().split()))
import fractions
from functools import reduce


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


lcm_a = lcm_list(Alist)
mod = 10**9 + 7
ans = 0

for a in Alist:
    ans += (lcm_a // a)
print(ans % mod)
### BUGGY CODE ###

def main():
  s = input()
  n = int(input())
  
  reverse_count = 0
  pre_s = ''
  after_s = ''
  for _ in range(n):
    t = list(input_list_str())
    if len(t) == 1:
      reverse_count += 1
      s = s[::-1]
      continue
    q, f, c = t
    if int(f) == 1:
      pre_s += c
      s = c + s
    else:
      after_s += c
      s = s + c
  
  print(s)
  exit()
  a = pre_s + s + after_s
  if reverse_count % 2 != 0:
    a = a[::-1]
  print(a)
    
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

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

import math
import fractions
from functools import reduce
main()

### FIXED CODE ###

def main():
  w = input()
  s = collections.deque(w)
  n = int(input())
  
  reverse_count = 0
  for i in range(n):
    t = list(input_list_str())
    if len(t) == 1:
      reverse_count = 1 - reverse_count
      continue
    q, f, c = t
    if int(f) + reverse_count == 2:
      s.append(c)
    else:
      s.appendleft(c)
  if reverse_count == 1:
    s.reverse()
  print(''.join(s))

    
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

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

import math
import fractions
import collections
from functools import reduce
main()
### BUGGY CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

N, X, Y = map(int,input().split())
l = [[0]*(N) for _ in range(N)]
for i in range(N-1):
    l[i][i+1] = 1
    l[i+1][i] = 1
l[X-1][Y-1] = 1
l[Y-1][X-1] = 1
csr = csr_matrix(l)
step = np.array(np.ravel(floyd_warshall(csr, unweighted=True)), dtype=int)
memo = np.bincount(step)
ma = np.max(step)
for i in range(1,ma+1):
    print(memo[i]//2)
for i in range(ma+1, N):
    print(0)

### FIXED CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

N, X, Y = map(int,input().split())
l = [[0]*(N) for _ in range(N)]
for i in range(N-1):
    l[i][i+1] = 1
    l[i+1][i] = 1
l[X-1][Y-1] = 1
l[Y-1][X-1] = 1
csr = csr_matrix(l)
step = np.array(np.ravel(dijkstra(csr, unweighted=True)), dtype=int)
memo = np.bincount(step)//2
ma = np.max(step)
for i in range(1,ma+1):
    print(memo[i])
for i in range(ma+1, N):
    print(0)
### BUGGY CODE ###

from bisect import bisect_left
import numpy as np
n,m,q=map(int,input().split())
s=[]
t=[]
ss=[]
for i in range(m):
    x,y=map(int,input().split())
    ss.append((x,y))
ss.sort()
for x,y in ss:
    s+=[x]
    t+=[y]
for i in range(q):
    x,y=map(int,input().split())
    bi=bisect_left(s,x)
    u=np.array(t[bi:])
    print(len(u[u<=y]))

### FIXED CODE ###

from itertools import accumulate
n,m,q=map(int,input().split())
s=[[0 for i in range(n)] for j in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    s[n-x][y-1]+=1
def f(s):
    for i in range(len(s)):
        s[i]=list(accumulate(s[i]))
f(s)
s=list(zip(*s))
f(s)
for i in range(q):
    x,y=map(int,input().split())
    print(s[y-1][n-x])
### BUGGY CODE ###

N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()

p = int(p) + 1

dic = {}

def my(N,p):
    for i in range(2,p+1):
        if p % i == 0:
            # print('ok')
            dic[i] = dic.get(i,0) + 1
            # print(dic)
            break
    p = p//i
    if p == 1:
        res = 1
        for j,k in dic.items():
            res *= j**(k//N)
        print(res)
        exit()
    else:
        my(N,p)

my(N,P)

### FIXED CODE ###

N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()

lim = int(p) + 1

dic = {}

def my(N,newP):
    for i in range(2,lim+1):
        while newP % i == 0:
            dic[i] = dic.get(i,0) + 1
            newP = newP // i
        if newP < i or i == lim:
            res = 1
            for j,k in dic.items():
                res *= j**(k//N)
            print(res)
            exit()
my(N,P)
### BUGGY CODE ###

A, B, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
discountDic = {}
for i in range(M):
    x, y, c = map(int, input().split(' '))
    key = (x-1)*B+(y-1)
    if key not in discountDic or discountDic[key] < c:
        discountDic[key] = c
priceList = []
for i in range(A):
    for j in range(B):
        price = a[i] + b[j]
        if i*B+j in discountDic:
            price -= discountDic[i*B+j]
        priceList.append(price)
print(min(priceList))

### FIXED CODE ###

A, B, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
discountDic = {}
for i in range(M):
    x, y, c = map(int, input().split(' '))
    key = (x-1)*B+(y-1)
    if key not in discountDic or discountDic[key] > a[x-1] + b[y-1] - c:
        discountDic[key] = a[x-1] + b[y-1] - c
discount_min_price = min(discountDic.values())
all_low_price = min(a) + min(b)
if discount_min_price < all_low_price:
    print(discount_min_price)
else:
    print(all_low_price)
### BUGGY CODE ###

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

for i in range(N):
    B = Q-A.count(i+1)
    if B >= K:
        print('No')
    else:
        print('Yes')


### FIXED CODE ###

n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]

cnt = [0] * n

for i in a:
    cnt[i - 1] += 1

for c in cnt:
    if k - (q - c) > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

K, S = map(int, input().split())

counter = 0

for i in range(K+1):
    x = i
    for ii in range(K+1):
        y = ii
        z = S - i - ii
        if 0<=z and z<=K and (x+y+z)==S:
            counter += 1

print(counter)            


### FIXED CODE ###

K, S = map(int, input().split())

counter = 0

for i in range(K+1):
    x = i
    for ii in range(K+1):
        y = ii
        z = S - i - ii
        if 0<=z and z<=K:
            counter += 1

print(counter)
### BUGGY CODE ###

n,k = (int(x) for x in input().split())
while abs(n-k) < n:
  n = abs(n-k)
print(n)

### FIXED CODE ###

n,k = (int(x) for x in input().split())
if n%k < k-(n%k):
  print(n%k)
else:
  print(k-(n%k))
### BUGGY CODE ###

import sys
import fractions
sys.setrecursionlimit(100000)
def lcm(x,y):
    return x/fractions.gcd(x,y)*y

n = int(input())
a = list(map(int,input().split()))
LCM=a[0]
for i in a:
  LCM = lcm(LCM,i)
ans=0
for i in a:
  ans += LCM/i
  
print(int(ans)%1000000007)


### FIXED CODE ###

import sys
import fractions
sys.setrecursionlimit(100000)
def lcm(x,y):
    return x//fractions.gcd(x,y)*y

n = int(input())
a = list(map(int,input().split()))
LCM=a[0]
for i in a:
  LCM = lcm(LCM,i)
ans=0
for i in a:
  ans += LCM//i
  
print(int(ans)%1000000007)
### BUGGY CODE ###

import math
import itertools
import numpy as np
n = int(input())
result = 0
list2 = list(range(1,n+1))
all = list(itertools.combinations_with_replacement(list2, 3))
for i in all:
    if(i[0]==i[1] and i[0]==i[2]):
        result += np.gcd.reduce(i)
    elif (i[0]==i[1] or i[0]==i[2] or i[1]==i[2]):
        result += np.gcd.reduce(i)*3
    else:
        result += np.gcd.reduce(i)*6
#print(all)
print(result)


### FIXED CODE ###

from math import gcd
ans = 0
k = int(input())
for i in range(1, k+1):
	for j in range(1, k+1):
		for l  in range(1, k+1):
			ans += gcd(gcd(i, j), l)
print(ans)
### BUGGY CODE ###

A, B, C, K = map(int, input().split())
ct = 0
if B == 0:
    if C == 0:
        print(A)
        exit()

for i in range(K):
    if A > 0:
        ct += 1
        A -= 1
    else:
        if B > 0:
            B -= 1
        else:
            ct -= 1
print(ct)


### FIXED CODE ###

A, B, C, K = map(int, input().split())
if (K - A) <= 0:
    print(K)
else:
    if (K - A - B) <= 0:
        print(A)
    else:
        c = (K - A - B)
        print(A - c)
### BUGGY CODE ###

#K : XYZそれぞれは、0以上K以下
#S : X+Y+Zの合計値を示すS

K,S = map(int,input().split())

X=Y=Z=0
result = 0
while(X<=S):
    while(X+Y<=S):
        Z = S-X-Y
        # print("X,Y,Z",X,Y,Z)
        if X+Y+Z == S:
            if X<=K and Y<=K and Z<=K :
                result+=1 
        # Z=X+Y-S
        # if X+Y+Z==S:
        #     result +=1
        # while(Z<=K):
        #     if X+Y+Z<S:
        #         pass
        #     elif X+Y+Z==S:
        #         result +=1
        #     else:
        #         break
        #     Z+=1
        # if X+Y+Z>S:
        #     break
        if Y<K:
            Y+=1
        else:
            break
    if X<K:
        Y=0
        X+=1
    else:
        break

print(result)

### FIXED CODE ###

#K : XYZそれぞれは、0以上K以下
#S : X+Y+Zの合計値を示すS

K,S = map(int,input().split())

X=Y=Z=0
result = 0
for x in range(K+1):
    for y in range ( K+1 ):
        if 0 <= S-X-Y <=K:
            result +=1
        # Z = S-X-Y
        # # print("XYZ",X,Y,Z)
        # if X+Y+Z == S:
        #     if  Z<=K :
        #         result+=1 
        Y+=1
    Y=0
    X+=1

print(result)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
N = int(input())
# 文字列の入力
s = input()
t = s.split(" ")
ans = []

for i in range(N):
    num = 0
    for j in range(len(t)):
        if int(t[j]) == i+1:
            num=num+1
    ans.append(num)

for i in ans:
    print(i)


### FIXED CODE ###

# -*- coding: utf-8 -*-
N = int(input())
# 文字列の入力
s = input()
t = s.split(" ")
#print(t)
ans = []
for i in range(N):
    ans.append(0)

#print(ans)

for i in range(len(t)):
    ans[int(t[i])-1]=ans[int(t[i])-1]+1

for i in ans:
    print(i)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
MOD = 10**9+7

n, k = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0]*(k+1) for _ in range(n+1)]
dp[0][0] = 1
for i, a in enumerate(A):
  for j in range(k+1):
    if j == 0:
      dp[i+1][j] = 1
    elif j <= a:
      dp[i+1][j] = dp[i+1][j-1] + dp[i][j]
    else:
      dp[i+1][j] = dp[i+1][j-1] + dp[i][j] - dp[i][j-a-1]
    dp[i+1][j] %= MOD
ans = dp[n][k]
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
MOD = 10**9+7

n, k = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0]*(k+1) for _ in range(n+1)]
dp[0][0] = 1
for i, a in enumerate(A):
  for j in range(k+1):
    if j == 0:
      dp[i+1][j] = 1
    elif j <= a:
      dp[i+1][j] = dp[i+1][j-1] + dp[i][j]
    else:
      dp[i+1][j] = dp[i+1][j-1] + dp[i][j] - dp[i][j-a-1]
    dp[i+1][j] %= MOD
ans = dp[n][k]
print(ans)
### BUGGY CODE ###

d = {"r": "p", "s": "r", "p": "s"}
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
score = {"r": r, "s": s, "p": p}
d2 = {}
r = 0


def set_hand(l, k):
    if l + k < n:
        if {d.get(t[l - k]), d.get(t[l + k])} == {"r", "s"}:
            return "p"
        if {d.get(t[l - k]), d.get(t[l + k])} == {"r", "p"}:
            return "s"
        if {d.get(t[l - k]), d.get(t[l + k])} == {"p", "s"}:
            return "r"
        return t[l]
    else:
        return t[l]


for i in range(n):
    for l in range(i, n, k):
        if d2.get(l) is not None:
            continue
        if l - k >= 0:
            if d2[l - k] == d.get(t[l]):
                d2[l] = set_hand(l, k)
            else:
                d2[l] = d.get(t[l])
                r += score[d2[l]]
        if l - k < 0:
            d2[l] = d.get(t[l])
            r += score[d2[l]]
print(r)


### FIXED CODE ###

d = {"r": "p", "s": "r", "p": "s"}
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
score = {"r": r, "s": s, "p": p}
d2 = {}
r = 0


def set_hand(l, k):
    if l + k < n:
        if {d.get(t[l - k]), d.get(t[l + k])} == {"r", "s"}:
            return "p"
        if {d.get(t[l - k]), d.get(t[l + k])} == {"r", "p"}:
            return "s"
        if {d.get(t[l - k]), d.get(t[l + k])} == {"p", "s"}:
            return "r"
        return t[l]
    else:
        return t[l]


for i in range(n):
    for l in range(i, n, k):
        if d2.get(l) is not None:
            break
        if l - k >= 0:
            if d2[l - k] == d.get(t[l]):
                d2[l] = set_hand(l, k)
            else:
                d2[l] = d.get(t[l])
                r += score[d2[l]]
        if l - k < 0:
            d2[l] = d.get(t[l])
            r += score[d2[l]]
print(r)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n = int(input())

ans = 0

for i in range(1,n):
    m = n - i
    soinsu = 0
    for j in range(1, m+1):
        if m % j == 0:
            soinsu += 1
    ans += soinsu

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
ans = 0
for i in range(1, n):
    ans += (n-1) // i
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
d = N // 2
# ans = []
# def linking_up():
ans_1 = [ i for i in range(N) if i % 2 == 0 and i != 0 and A.count(i) == 2 and A.count(0) == 1]
    # for i in range(N):
        # if i % 2 == 0 and i != 0:
            # if A.count(i) == 2 and A.count(0) == 1:
                # ans.append('c')
ans_2 = [ i for i in range(N) if i % 2 and A.count(i) == 2]
        # else:
            # if A.count(i) == 2:
                # ans.append('a')
# linking_up()
if len(ans_1) == d or len(ans_2) == d:
    print(2 ** d)
else:
    print(0)
        




### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
mod=10**9+7
if n%2==0:
  for i in range(n):
    if a[i]!=(i//2)*2+1:
      print(0)
      exit()
  print(pow(2,n//2,mod))
else:
  for i in range(n):
    if a[i]!=((i+1)//2)*2:
      print(0)
      exit()
  print(pow(2,n//2,mod))
### BUGGY CODE ###

N, M = map(int, input().split())

node = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    node[a].append(b)
    node[b].append(a)

q = [0]
ans = [-1] * N
kyo = [99999999999999] * N
kyo[0] = 0
while(len(q) > 0):
    now = q.pop()
    for i in node[now]:
        if kyo[i] > kyo[now] + 1:
            q.append(i)
            ans[i] = now
            kyo[i] = kyo[now] + 1


print("Yes")
for i in range(1, N):
    print(ans[i] + 1)


### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())

node = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    node[a].append(b)
    node[b].append(a)

q = deque([0])
ans = [-1] * N
while(len(q) > 0):
    now = q.popleft()

    for i in node[now]:
        if ans[i] == -1:
            q.append(i)
            ans[i] = now


print("Yes")
for i in range(1, N):
    print(ans[i] + 1)
### BUGGY CODE ###

n=int(input())
for i in range(10):
    print(i)
    s=input()

### FIXED CODE ###

N = int(input())
print(0)
res = input()
if res == "Vacant":
    exit(0)

print(N-1)
res2 = input()
if res2 == "Vacant":
    exit(0)
seat = [""]*N
seat[0] = res
seat[N-1] = res

first = 0
last = N-1

for i in range(18):
    ret = (first + last) // 2
    if ret == first:
        ret += 1
    print(ret)
    res = input()
    seat[ret] = res
    if res == "Vacant":
        exit(0)
    else:
        if (res == seat[first] and (ret - first) % 2 == 0) or (res != seat[first] and (ret - first) % 2 == 1):
            first = ret
        else:
            last = ret-1
### BUGGY CODE ###

n = int(input())
s = list(map(int, input().rstrip()))

ans = 0
for i in range(1000):
    if i < 10:
        x, y, z = 0, 0, i
    elif i < 100:
        x, y, z = 0, i // 10, i % 10
    else:
        x = i // 100
        y = (i - x * 100) // 10
        z = i % 10
    flg = 0
    for a in range(len(s) - 2):
        if flg == 1:
            break
        elif x != s[a]:
            continue
        else:
            for b in range(a + 1, len(s) - 1):
                if flg == 1:
                    break
                elif y != s[b]:
                    continue
                else:
                    for c in range(b + 1, len(s)):
                        if z != s[c]:
                            continue
                        else:
                            ans += 1
                            flg = 1
                            break

print(ans)

### FIXED CODE ###

n = int(input())
s = list(map(int, input().rstrip()))

ans = 0
for i in range(10):
    if i in s[:n - 2]:
        x = s.index(i)

        for j in range(10):
            if j in s[x + 1:n - 1]:
                y = x + s[x + 1:n - 1].index(j) + 1

                for k in range(10):
                    if k in s[y + 1:]:
                        ans += 1

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

n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
    poplist = a[:i] + a[i+1:]
    print(max(poplist))


### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]

max_value = max(a)
max_index = a.index(max_value)

for i in range(n):
    if not i == max_index:
        print(max_value)
    else:
        newlist = a[:i] + a[i+1:]
        print(max(newlist))
### BUGGY CODE ###

N = int(input())
employee = list(map(int, input().split()))
for i in range(1, N+1):
    print(employee.count(i))

### FIXED CODE ###

N = int(input())
employee = list(map(int, input().split()))
subordinate = [0] * N
for i in range(N-1):
    subordinate[employee[i]-1] += 1
for s in subordinate:
    print(s)
### BUGGY CODE ###

import numpy as np

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
wk=0
aa=[]
bb=[]
for i in a:
    wk+=i
    aa.append(wk)
wk=0
for i in b:
    wk+=i
    bb.append(wk)
ak=np.array(aa)
bk=np.array(bb)

ass = len([1 for i in ak if i<=k]) 
bs = len([1 for i in bk if i<=k]) 

an=0
for i in range(ass-1,-1,-1):
    wk = len([1 for j in bk if j<=(k-ak[i])]) 
    an=max(an,(i+1+wk))
an=max(an,ass)
an=max(an,bs)

print(an)

### FIXED CODE ###

import numpy as np

n,m,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
b=np.array(list(map(int,input().split())))

ak=np.cumsum(a,dtype=np.int64)
bk=np.cumsum(b,dtype=np.int64)
ak=ak[ak<=k]
bk=bk[bk<=k]
lak=len(ak)
lbk=len(bk)

an=lak
j=0
for i in range(lak-1,-1,-1):
    while bk[j]+ak[i]<=k:
        an=max(an,i+j+2)
        j+=1
        if j>=lbk:
            j-=1
            break
an=max(an,lbk)

print(an)
### BUGGY CODE ###

import copy
import collections

def calc(k, balls):
    balls_count = set(copy.copy(balls))
    change_count = 0
    flg = True

    while flg == True:
        if len(balls_count) <= int(k):
            flg = False
            return change_count
        else:
            c = collections.Counter(balls)
            most_common = c.most_common()[-1]
            balls = [i for i in balls if i != most_common[0]]
            balls_count = sorted(set(copy.copy(balls)))
            change_count += int(most_common[1])


_ = input().split()
k = _[1]
balls = sorted(input().split())

print(calc(k, balls))

### FIXED CODE ###

import copy
import collections

def calc(k, balls):
    dif = len(set(copy.copy(balls))) - int(k)
    change_count = 0

    if dif <= 0:
        return change_count
    else:
         c = collections.Counter(balls)
         most_common = c.most_common()[::-1]
         for x in most_common:
             change_count = change_count +  x[1]
             dif = dif - 1
             if dif <= 0 :
                break
         return change_count


_ = input().split()
k = _[1]
balls = sorted(input().split())

print(calc(k, balls))
### BUGGY CODE ###

N = int(input()) + 1
power = 1
for i in range(1,N):
    power*=i

print(power%(10**9+7))


### FIXED CODE ###

N = int(input()) + 1
power = 1
for i in range(1,N):
    power*=i
    power %= 10**9+7

print(power)
### BUGGY CODE ###

def check():
    s=input()
    t=input()

    for i in range(len(s)):
        if s[i]==t[i]:
            continue
        si=s[i]
        ti=t[i]
        t=t.replace(ti, "?")
        t=t.replace(si, ti)
        t=t.replace("?", si)
    
    if s==t:
        return "Yes"
    else:
        return "No"

print(check())        


### FIXED CODE ###

def check():
    s=input()
    t=input()

    d={}

    for i in range(len(s)):
        si=s[i]
        ti=t[i]
        if not si in d:
            d[si]=ti
        else:
            if d[si]==ti:
                continue
            else:
                return "No"
            
    vals=d.values()
    if len(vals)==len(set(vals)):
        return "Yes"
    else:
        return "No"
print(check())