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

n = int(input())
c = list(input())#ciが R のとき赤、W のとき白
count = n
a = 0
b = 0
 
for i in range(n):
  if i == 0:
    ans = c.count("R")
    count = min(ans, count)
  elif i == n-1:
    ans = c.count("W")
    count = min(ans, count)
  else:
    a = c[0:i].count("W")
    b = c[i:].count("R")
    ans = max(a, b)
    count = min(ans, count)
print(count)
 

### FIXED CODE ###

n = int(input())
c = list(input())#ciが R のとき赤、W のとき白
a = c.count("R")
b = 0
count = max(a, b)
# a: R->W, b: W->Rの回数
for i in range(n):
  if c[i] == "R":
    a = a - 1
  else:
    b = b + 1
  ans = max(a, b)
  count = min(ans, count)
print(count)
### BUGGY CODE ###

N,W = map(int,input().split())
w = []
v = []
for i in range(N):
    x,y = map(int,input().split())
    w.append(x)
    v.append(y)

dp = [[0]*(W+1) for j in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i])

print(dp[N][W])

### FIXED CODE ###

n,W = map(int,input().split())
w = []
v = []
for i in range(n):
    x,y = map(int,input().split())
    w.append(x)
    v.append(y)

dp = [[0]*(W+1) for j in range(n+1)]

for i in range(n-1,-1,-1):
    for j in range(W+1):
        if j < w[i]:
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j],dp[i+1][j-w[i]]+v[i])
print(dp[0][W])
### BUGGY CODE ###

def popcount(n):
    cnt = 0
    for i in range(n):
        if ((n >> i) & 1):
            cnt +=1
    return cnt

def f(n):
    cnt = 1
    while True:
        if n == 0:
            break
        n = n % popcount(n)
        cnt += 1
    return cnt

def pow(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def numChange(list, num):
    i = len(list) - 1
    j = 0
    ans = 0
    while i >= 0:
        if list[i] == '1':
            ans += num[j]
        i -= 1
        j += 1
    return ans

if __name__ == "__main__":
    n = int(input())
    x = list(input())
    d = sum([y == '1' for y in x])
    num = []
    a = 1
    for i in range(n):
        num.append(a)
        a *= 2
    xNum = numChange(x, num)
    for i in range(n):
        if x[i] == "1":
            wk = xNum - num[len(x) - i - 1]
            wkd = d - 1
        else:
            wk = xNum + num[len(x) - i - 1]
            wkd = d + 1
        if wk == 0:
            print(0)
        else:
            wk %= wkd
            if wk == 0:
                print(1)
            else:
                print(f(wk))


### FIXED CODE ###

def f(n):
    cnt = 1
    while n > 0:
        n  %= bin(n).count('1')
        cnt += 1
    return cnt

if __name__ == "__main__":
    n = int(input())
    x = input()
    d = x.count('1')
    if d == 1:
        for i in x[:-1]:
            if i == '0':
                print(1)
            else:
                print(0)
        if x[-1] == '1':
            print(0)
        else:
            print(2)
        exit()

    ans = []
    M = 0
    for i in x:
        M <<= 1
        if i == '1':
            M += 1
    p = M % (d + 1)
    m = M % (d - 1)
    for i in range(n):
        if x[i] == '0':
            ans.append(f((p + pow(2, n - i - 1, d + 1)) % (d + 1)))
        else:
            ans.append(f((m - pow(2, n - i - 1, d - 1)) % (d - 1)))
    print(*ans, sep='\n')
### BUGGY CODE ###

N, K, *A = map(int, open(0).read().split())
B = sorted(map(lambda x:A.count(x), set(A)))
print(sum(B[:-K]))

### FIXED CODE ###

import collections as cl
N, K, *A = map(int, open(0).read().split())
c = sorted(cl.Counter(A).values())
print(sum(c[:-K]))
### BUGGY CODE ###

def myAnswer(S:list) -> int:
   N = len(S)
   counter = 0
   for i in range(N):
      for j in range(N-1,i,-1):
         if(S[j]> S[j-1]):
            S[j],S[j-1] = S[j -1],S[j]
            counter += 1
   return counter

def modelAnswer():
   tmp=1
def main():
   S = list(input())
   print(myAnswer(S[:]))
if __name__ == '__main__':
   main()

### FIXED CODE ###

def myAnswer(S:list) -> int:
   N = 0
   counter = 0
   for n,s in enumerate(S):
      if(s == "W"):
         counter += n - N
         N += 1
         

   return counter

def modelAnswer():
   tmp=1
def main():
   S = list(input())
   print(myAnswer(S[:]))
if __name__ == '__main__':
   main()
### BUGGY CODE ###

import sys,math
import numpy as np

n=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')
ans=0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=math.gcd(math.gcd(i,j),k)

print(ans)


### FIXED CODE ###

import sys,math
import numpy as np

n=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')
ans=0
for i in range(1,n+1):
    ans+=i
    if i!=n:
        for j in range(i+1,n+1):
            f=math.gcd(i,j)
            ans+=f*6
            if j!=n:
                for k in range(j+1,n+1):
                    ans+=math.gcd(f,k)*6

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

n, k = map(int, input().split())
a = list(map(int, input().split()))
results = []
for i in range(k - 1, n):
    result = 1
    for j in range(k):
        result *= a[i - j]
    results.append(result)
for i in range(1, len(results)):
    if results[i - 1] < results[i]:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

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

for i in range(k, n):
    if a[i - k] < a[i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

import numpy as np

inf=10**7
n=int(input())
coin=[6**x for x in range(10)]
coin+=[9**x for x in range(1,10)]

dp=np.zeros(n+1,dtype=np.int64)
dp+=inf
dp[0]=0

for i in range(n+1):
    for x in coin:
        if(i+x<=n):
            dp[i+x]=min(dp[i+x],dp[i]+1)
print(dp[-1])

### FIXED CODE ###


inf=10**7
n=int(input())

ad=[6**x for x in range(10)]
ad2=[9**x for x in range(1,10)]
ad.extend(ad2)

a=[inf]*(n+1)
a[0]=0
for i in range(n+1):
    for x in ad:
        if(x+i<=n):a[x+i]=min(a[x+i],a[i]+1)



print(a[n])
### BUGGY CODE ###

n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]+[10**10]
t.sort()
b=1
p=0
while p<n:
  l=t[p]+k
  pp=1
  f=1
  while pp<c and f:
    p+=1
    if t[p]<=l:
      pp+=1
      if pp==c:
        p+=1
    else:
      f=0
  if p<n:
    b+=1
print(b)

### FIXED CODE ###

n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]+[10**10]
t.sort()
b=1
p=0
if c==1:
  print(n)
  exit()
while p<n:
  l=t[p]+k
  pp=1
  f=1
  while pp<c and f:
    p+=1
    if t[p]<=l:
      pp+=1
      if pp==c:
        p+=1
    else:
      f=0
  if p<n:
    b+=1
print(b)
### BUGGY CODE ###

MOD = 10**9+7

def extgcd(a,b): #互いに素なa,bについて、a*x+b*y=1の一つの解
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

def mod_inv(a,mod): # (x/a)%MODをしたい時は x%MOD * mod_inv(a,MOD)%MOD
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod


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

def lcm(a, b):
    return a*b//gcd(a,b)

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

lcm_ = a[0]
ans = 1
for i in range(1,n):
    if lcm_ % a[i] != 0:
        if lcm_%MOD * mod_inv(a[i],MOD)%MOD != 0:
            lcm_new = lcm(lcm_, a[i])
            ans = ans*(lcm_new%MOD *mod_inv(lcm_,MOD)%MOD)
            lcm_ = lcm_new
    ans += lcm_%MOD * mod_inv(a[i], MOD)%MOD

print(ans%MOD)






### FIXED CODE ###

MOD = 10**9+7
import fractions

def extgcd(a,b): #互いに素なa,bについて、a*x+b*y=1の一つの解
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

def mod_inv(a,mod): # (x/a)%MODをしたい時は x%MOD * mod_inv(a,MOD)%MOD
    x = extgcd(a,mod)[0]
    return (mod+x%mod)%mod


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

# def lcm(a, b):
#     return a*b//gcd(a,b)

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

lcm_ = a[0]
for i in range(1, n):
    lcm_ = lcm_ * a[i] // fractions.gcd(lcm_, a[i])

# lcm_ = a[0]
ans = 0
for i in range(0,n):
    # if lcm_ % a[i] != 0:
    #     lcm_new = lcm(lcm_, a[i])
    #     ans = ans*(lcm_new%MOD *mod_inv(lcm_,MOD)%MOD)
    #     lcm_ = lcm_new

    ans += lcm_%MOD * mod_inv(a[i], MOD)%MOD

print(ans%MOD)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
result = []
for i in range(1, N+1):
    result.append(A.index(i) + 1)

print(' '.join(map(str, result)))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
result = [0] * (N + 1)
for i in range(1, N+1):
    result[A[i - 1]] = i

print(' '.join(map(str, result[1::])))
### BUGGY CODE ###

N = int(input())
array = list(map(int, input().split()))
cnt = 0

for i in range(0, N):
    flag = 0
    for j in range(0, i):
        if array[i] > array[j]:
            break
    else:
        cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())
array = list(map(int, input().split()))
cnt = 1
minv = array[0]

for i in range(1, N):
    if minv > array[i]:
        minv = array[i]
        cnt += 1
print(cnt)
### BUGGY CODE ###

#!/usr/bin/env python

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

# calc
middle = []
ok = False
for i in range(m):
    if a[i] == 1:
        middle.append(b[i])
for i in range(len(middle)):
    for j in range(m):
        if a[j] == middle[i] and b[j] == n:
            ok = True
if ok: 
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


### FIXED CODE ###

#!/usr/bin/env python
from collections import deque

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

if m == 1:
    print('IMPOSSIBLE')
    exit()

to = [[] for _ in range(n+1)]
for i in range(m):
    to[a[i]].append(b[i])
    to[b[i]].append(a[i])
#print('to =', to)

# BFS
inf = 200200
dist = [inf for _ in range(n+1)]
q = deque()
q.append(1)
dist[1] = 0 

while q:
    v = q.popleft()
    for u in to[v]:
        if dist[u] == inf:
            dist[u] = dist[v]+1
            q.append(u)

if dist[n] == 2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

dd = [(1,0),(0,1),(-1,0),(0,-1)]
h,w = inpl()
cy,cx = inpl()
gy,gx = inpl()
cy,cx,gy,gx = cy-1,cx-1,gy-1,gx-1
s = [input() for _ in range(h)]
res = [INF] * (h*w)
q = deque([(cy,cx)])
res[cy*w+cx] = 0
while q:
    oy,ox = q.popleft()
    for dy in range(-2,3):
        for dx in range(-2,3):
            ny = dy + oy
            nx = dx + ox
            if 0 <= ny < h and 0 <= nx < w and s[ny][nx] == '.':
                f = False
                if (dy,dx) in dd:
                    if res[ny*w+nx] > res[oy*w+ox]:
                        f = True
                        res[ny*w+nx] = min(res[ny*w+nx], res[oy*w+ox])
                else:
                    if res[ny*w+nx] > res[oy*w+ox] + 1:
                        f = True
                        res[ny*w+nx] = min(res[ny*w+nx], res[oy*w+ox] + 1)
                if f: q.append((ny,nx))
print(res[gy*w+gx] if res[gy*w+gx] != INF else -1)


### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

dd = [(1,0),(0,1),(-1,0),(0,-1)]
h,w = inpl()
cy,cx = inpl()
gy,gx = inpl()
cy,cx,gy,gx = cy-1,cx-1,gy-1,gx-1
s = [input() for _ in range(h)]
res = [[INF] * w for _ in range(h)]
res[cy][cx] = 0
seen = set()
q = deque([(cy,cx)])
while q:
    oy,ox = q.popleft()
    if (oy,ox) in seen: continue
    seen.add((oy,ox))
    for dy,dx in dd:
        ny = oy+dy; nx = ox+dx
        if 0 <= ny < h and 0 <= nx < w and s[ny][nx] == '.':
            if res[ny][nx] > res[oy][ox]:
                res[ny][nx] = res[oy][ox]
                q.appendleft((ny,nx))
        for dy in range(-2,3):
            for dx in range(-2,3):
                ny = oy+dy; nx = ox+dx
                if 0 <= ny < h and 0 <= nx < w and s[ny][nx] == '.':
                    if res[ny][nx] > res[oy][ox] + 1:
                        res[ny][nx] = res[oy][ox] + 1
                        q.append((ny,nx))
ans = res[gy][gx]
print(-1 if ans  == INF else ans)
### BUGGY CODE ###

from collections import deque

n = int(input())
node_list = []
nodes = [[] for _ in range(n)]
edges = dict()
for _ in range(n - 1):
	a, b = map(int, input().split())
	node_list.append((a - 1, b - 1))
	nodes[a - 1].append(b - 1)
	nodes[b - 1].append(a - 1)
	edges[(a - 1, b - 1)] = 0

used = [False] * n
que = deque()
que.append(0)
while len(que) > 0:
	ni = que.pop()
	if used[ni]:
		continue
	used_colors = [edges[tuple(sorted((ni, e)))] for e in nodes[ni]]
	unused = deque([c for c in range(n, 0, -1) if not c in used_colors])
	for node in nodes[ni]:
		[a, b] = sorted([ni, node])
		if edges[(a, b)] == 0:
			# print((a, b), unused)
			edges[(a, b)] = unused.pop()
			# print(edges[(a, b)])
		que.append(node)

	used[ni] = True

print(max(edges.values()))
for node in node_list:
	print(edges[node])


### FIXED CODE ###

from collections import deque

n = int(input())
nodes = [[] for _ in range(n)]
node_list = []
for _ in range(n - 1):
	a, b = map(int, input().split())
	nodes[a - 1].append(b - 1)
	node_list.append(b - 1)
 
que = deque([0])
ans = [0] * n
while len(que) > 0:
	ni = que.pop()
	color = 1
	for node in nodes[ni]:
		if color == ans[ni]:
			color += 1
		ans[node] = color
		color += 1
		que.append(node)
 
print(max(ans))
for node in node_list:
	print(ans[node])
### BUGGY CODE ###

N=int(input())
sisterN=[]
SISTERn=[]
SISterN=[]
for n in range(N):
    _=int(input())
    if _<50000:
        _s= _
        if sisterN.count(_s)==1:
            sisterN.remove(_s)
        else:
            sisterN.append(_s)
    elif 50001<_<80000:
        _m= _
        if SISterN.count(_m)==1:
            SISterN.remove(_m)
        else:
            SISterN.append(_m)
    elif 80001<_:
        _b= _
        if SISTERn.count(_b)==1:
            SISTERn.remove(_b)
        else:
            SISTERn.append(_b)

print(len(sisterN)+len(SISTERn)+len(SISterN))



### FIXED CODE ###

N=int(input())
S=set()

for n in range(N):
    _=int(input())
    if _ in S:
        S.remove(_)
    else:
        S.add(_)

print(len(S))
### BUGGY CODE ###

# coding: utf-8

N, Q = map(int, input().split())
S = input()
l_r = [tuple(map(int, input().split())) for _ in range(Q)]

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

for l, r in l_r:
    print(sum(isAC[l - 1:r - 1]))


### FIXED CODE ###

# coding: utf-8

N, Q = map(int, input().split())
S = input()
l_r = [tuple(map(int, input().split())) for _ in range(Q)]

isAC = [0] * N
cnt = 0
for i in range(len(S) - 1):
    if S[i] == "A" and S[i + 1] == "C":
        cnt += 1
    isAC[i + 1] = cnt

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

A, B = map(int, input().split())

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

def coprime(a, b):
    return gcd(a, b) == 1

mini = min(A, B)
cmlist = []
for i in range(1, mini+1):
  if A % i == 0 and B % i == 0:
    can_append = True
    for cm in cmlist:
      if not coprime(cm, i):
        can_append = False
        break
    if can_append:
	    cmlist.append(i)

print(len(cmlist))

### FIXED CODE ###

A, B = map(int, input().split())

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

def coprime(a, b):
    return gcd(a, b) == 1
 
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

cmlist = sorted(list(set(divisor(A)) & set(divisor(B))))
res = []
for cm1 in cmlist:
  can_append = True
  for cm2 in res:
    if not coprime(cm1, cm2):
      can_append = False
      continue
  if can_append:
    res.append(cm1)
print(len(res))
### BUGGY CODE ###

n = int(input())
l = [int(i) for i in input().split()]
l.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[k] < l[i] + l[j]:
                ans += 1
print(ans)


### FIXED CODE ###

import bisect
n = int(input())
l = [int(i) for i in input().split()]
l.sort()
k = 0
for i in range(n):
    for j in range(i + 1, n):
        ind = bisect.bisect_left(l, l[i] + l[j])
        k += max(ind-j-1, 0)
print(k)
### BUGGY CODE ###

H,N = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b =map(int,input().split())
    A.append(a)
    B.append(b)

G = [[0]*(H+1) for _ in range(N+1)]

for i in range(H+1):
    G[0][i] = 10**9

for i in range(1,N+1):
    for j in range(1,H+1):
        if j-A[i-1]<0:
            G[i][j] = min(G[i -1][j], B[i-1])
        else:
            G[i][j] = min(G[i -1][j], G[i][j-A[i-1]]+B[i-1])

print(G[N][H])

### FIXED CODE ###

H,N = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b =map(int,input().split())
    A.append(a)
    B.append(b)

G = [0]*(H+1)

for i in range(1,N+1):
    for j in range(1,H+1):
        if i == 1:
            if j-A[i-1]<0:
                G[j] = B[i-1]
            else:
                G[j] = G[j-A[i-1]]+B[i-1]
        elif j-A[i-1]<0:
            G[j] = min(G[j], B[i-1])
        else:
            G[j] = min(G[j], G[j-A[i-1]]+B[i-1])
        
print(G[H])
### BUGGY CODE ###

N = int(input())
L=input().split(' ')
NL = [int(i) for i in L]

counter=0

for i in range(N):
    try:
        index = NL.index(i+1)
    except:
        break
    else:
        NL = NL[index+1:]
        counter += 1


if(counter == 0):
    print(-1)
else:
    print(N - counter)

### FIXED CODE ###

N = int(input())
L=input().split(' ')
NL = [int(i) for i in L]

counter=0
start = 0
end = N

for i in range(N):
    try:
        index = NL.index(i+1, start, end)
        start = index+1
    except:
        break
    else:
        counter += 1


if(counter == 0):
    print(-1)
else:
    print(N - counter)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
A,B,Q=map(int,input().split())

def bisearch(target,lis):
    low=0
    high=len(lis)-1
    if lis[0]>target:
        return low-1
    elif lis[-1]<target:
        return high
    
    while lis[low]>target or lis[low+1]<target:
        mid=(low+high)//2
        if lis[mid]<target:
            high=mid
        else:
            low=mid
    return low

def cand(num,lis):
    N=len(lis)-1
    a=max(num,0)
    b=min(num+1,N)
    return [lis[a],lis[b]]

god=[]
for _ in range(A):
    god.append(int(input()))

buddha=[]
for _ in range(B):
    buddha.append(int(input()))

for _ in range(Q):
    q=int(input())
    g_i=(bisearch(q,god))
    b_i=(bisearch(q,buddha))
    G=cand(g_i,god)
    B=cand(b_i,buddha)
    ans=10**18
    for g in G:
        for b in B:
            ans=min(ans,abs(q-g)+abs(g-b),abs(q-b)+abs(b-g))
    print(ans)


### FIXED CODE ###

# coding: utf-8
# Your code here!
import bisect

A,B,Q=map(int,input().split())

god=[-10**18]
for _ in range(A):
    god.append(int(input()))
god.append(10**18)

buddha=[-10**18]
for _ in range(B):
    buddha.append(int(input()))
buddha.append(10**18)

#print(god,buddha)
for _ in range(Q):
    q=int(input())
    g_i=bisect.bisect_left(god, q)
    b_i=bisect.bisect_left(buddha, q)
    #print(g_i,b_i)
    
    ans=10**18
    G=[god[g_i-1],god[g_i]]
    B=[buddha[b_i-1],buddha[b_i]]
    for g in G:
        for b in B:
            ans=min(ans,abs(q-g)+abs(g-b),abs(q-b)+abs(b-g))
    print(ans)
### BUGGY CODE ###

import itertools

n = int(input())
lis = tuple(input())

ans = tuple(itertools.combinations(lis, 3))

result = []
for line in ans:
    if line not in result:
        result.append(line)
print(len(result))


### FIXED CODE ###

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

dp1 = [[0 for i in range(10)] for _ in range(n + 1)]
dp2 = [[0 for i in range(100)] for _ in range(n + 1)]
dp3 = [[0 for i in range(1000)] for _ in range(n + 1)]

for i in range(n):
    dp1[i + 1][int(s[i])] = 1
    for j in range(10):
        if dp1[i][j]:
            dp2[i + 1][j * 10 + int(s[i])] = 1
            dp1[i + 1][j] = 1
    for j in range(100):
        if dp2[i][j]:
            dp3[i + 1][j * 10 + int(s[i])] = 1
            dp2[i + 1][j] = 1
    for j in range(1000):
        if dp3[i][j]:
            dp3[i + 1][j] = 1

print(sum(dp3[n]))
### BUGGY CODE ###

def acNumberInString(word):
  count = 0
  for i in range(len(word) - 1):
    if word[i] == 'A' and word[i+1] == 'C':
      count += 1
  return count


N, Q = map(int, input().split())
S = input()
for q in range(Q):
  start, end = map(int, input().split())
  tmp_word = S[start-1:end]
  print(acNumberInString(tmp_word))


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
AC_numbers = [0]

# そうか、まず累積和で全体のACのかずを数えるのか
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    AC_numbers.append(AC_numbers[i - 1] + 1)
  else:
    AC_numbers.append(AC_numbers[i-1])

# そこから引いて数を求める
for q in range(Q):
  start, end = map(int, input().split())
  count = AC_numbers[end-1] - AC_numbers[start-1]
  print(count)
### BUGGY CODE ###

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

ans_lst=[]
for i in range(1,n+1):
    ans_lst.append(str(h.index(i)+1))
print(' '.join(ans_lst))


### FIXED CODE ###

from sys import stdin
input = stdin.readline

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

ans_lst=[None]*n
for i,h[i] in enumerate(h):
    ans_lst[h[i]-1]=i+1
print(*ans_lst)
### BUGGY CODE ###

n = int(input())

string = []
count = 0
# a-z : 0-25
# print(ord('a')-97, ord('z')-97)

table = [[0 for i in range(26)] for _ in range(n)]

for i in range(n):
    for s in str(input()):
        table[i][ord(s)-97] += 1

for i in range(n):
    for j in range(i, n):
        if (i != j) and (table[i] == table[j]):
            count += 1
            
print(count)

### FIXED CODE ###

n = int(input())
 
string = {}
count = 0

for i in range(n):
    base = sorted(input())

    if string.get("".join(base)) != None:
        count += int(string["".join(base)])
        string["".join(base)] += 1
    else:
        string["".join(base)] = 1

print(count)