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

N=int(input())
S=list(map(str,input()))
ans=0

for i in range(N-2):
  for j in range(N-i-2):
    if S[i]!=S[i+j+1]:
      A=["R","B","G"]
      A.remove(S[i])
      A.remove(S[i+j+1])
      for k in range(N-i-j-2):
        if A[0]==S[i+j+k+2] and j!=k:
          ans+=1

print(str(ans))

### FIXED CODE ###

N=int(input())
S=list(map(str,input()))
L=[0,0,0]
for i in range(N):
  if S[i]=="R":
    L[0]+=1
  elif S[i]=="G":
    L[1]+=1
  elif S[i]=="B":
    L[2]+=1
ans=L[0]*L[1]*L[2]

for i in range(N-2):
  for j in range(int((N-i-1)/2)):
    if S[i]!=S[i+j+1] and S[i]!=S[i+2*j+2] and S[i+j+1]!=S[i+2*j+2]:
      ans-=1

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

import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,M = map(int, input().split())
    bridges = [False]*(N-1)
    closest_enemy = [-1]*N
    for _ in range(M):
        a,b = map(int, input().split())
        closest_enemy[b-1] = max(a-1,closest_enemy[b-1])
    for i in range(1,N):
        if closest_enemy[i] < 0: continue

        if True in bridges[closest_enemy[i]:i]:
            continue
        else:
            bridges[i-1] = True
    print(bridges.count(True))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,M = map(int, input().split())
    battles = [[] for _ in range(N)]
    for _ in range(M):
        a,b = map(int, input().split())
        battles[b-1].append(a-1)

    x = -1
    ans = 0
    for i in range(1,N):
        battle = battles[i]
        if len(battle) == 0: continue

        closest_idx = max(battle)
        if x < closest_idx:
            ans += 1
            x = i-1
    print(ans)

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

N, K = map(int, input().split())
V = list(map(int, input().split()))

def opA(D, v):
  if len(v) != 0:
    D.append(v.pop(0))
  return D, v

def opB(D, v):
  if len(v) != 0:
    D.append(v.pop(-1))
  return D, v

def opC(D, v):
  if len(D) != 0:
    v.insert(0, min(D))
    D.remove(min(D))
  return D, v

def opD(D, v):
  if len(D) != 0:
    v.append(min(D))
    D.remove(min(D))
  return D, v

def dp(n, D, v, op):
  if n == K:
    return sum(D)
  
  if op == 0:
    D, v = opA(D, v)
  elif op == 1:
    D, v = opB(D, v)
  elif op == 2:
    D, v = opC(D, v)
  else:
    D, v = opD(D, v)
  return max(dp(n + 1, D.copy(), v.copy(), 0), dp(n + 1, D.copy(), v.copy(), 1), dp(n + 1, D.copy(), v.copy(), 2), dp(n + 1, D.copy(), v.copy(), 3))

print(max(dp(0, [], V.copy(), 0), dp(0, [], V.copy(), 1), dp(0, [], V.copy(), 2), dp(0, [], V.copy(), 3)))

### FIXED CODE ###

N, K = map(int, input().split())
V = list(map(int, input().split()))

R = min(N, K)
l = []
ans = 0
for a in range(R + 1):
  for b in range(R + 1 - a):
    l = V[:a] + V[N - b:]
    l.sort()
    for i in range(K - a - b + 1):
      ans = max(ans, sum(l[i:]))
print(max(ans, 0))
### BUGGY CODE ###

def main():
	n=input()
	List_1=[]
	for i in range(n):
		List_1.append(input())
		if i==1:
			max=List_1[1]-List_1[0]
		elif i>1:
			for j in range(i-1,-1,-1):
				if max<List_1[i]-List_1[j]:
					max=List_1[i]-List_1[j]
	print(max)

if __name__=='__main__':
	main()

### FIXED CODE ###

n=input()
for i in range(n):
	if i==0:
		num_1=input()
	elif i==1:
		num_2=input()
		maxv=num_2 - num_1
		MIN=min(num_1,num_2)
	else:
		num_3=input()
		if (num_3-MIN)>maxv:
			maxv=num_3-MIN
		if (num_3)<MIN:
			MIN=num_3
print(maxv)
### BUGGY CODE ###

from collections import deque
H,W = map(int,input().split())
Ch,Cw = map(int,input().split())
Dh,Dw = map(int,input().split())
S = []
for _ in range(H):
    S.append(list(input()))

warp = [[-1 for i in range(W)]for j in range(H)]

Q = deque([[Ch-1,Cw-1,0]])

while(len(Q) != 0):
    x,y,cnt = Q.popleft()

    if(warp[x][y] != -1):   #skip
        continue

    warp[x][y] = cnt        #ワープ魔法の必要回数

    for tx in range(-2,3):
        for ty in range(-2,3):
            nx = x+tx
            ny = y+ty

            if(0 <= nx < H and 0<= ny < W and S[nx][ny]=="."):
                if(abs(tx)+abs(ty) == 1):#徒歩で行けるなら前に
                    Q.appendleft([nx,ny,cnt])
                elif(abs(tx)+abs(ty)>=2):#ワープ魔法必要なら後ろに
                    Q.append([nx,ny,cnt+1])

print(warp[Dh-1][Dw-1])

### FIXED CODE ###

from collections import deque
H,W = map(int,input().split())
Ch,Cw = map(int,input().split())
Dh,Dw = map(int,input().split())
S = []
for _ in range(H):
    S.append(list(input()))

warp = [[-1 for i in range(W)]for j in range(H)]

Q = deque([[Ch-1,Cw-1,0]])

while(len(Q) != 0):
    x,y,cnt = Q.popleft()

    if(warp[x][y] != -1):   #skip
        continue

    warp[x][y] = cnt        #ワープ魔法の必要回数

    for tx in range(-2,3):
        for ty in range(-2,3):
            nx = x+tx
            ny = y+ty

            if(0 <= nx < H and 0<= ny < W and S[nx][ny]=="."):
                if(abs(tx)+abs(ty) == 1):#徒歩で行けるなら前に
                    Q.appendleft([nx,ny,cnt])
                elif(abs(tx)+abs(ty)>=2):#ワープ魔法必要なら後ろに
                    Q.append([nx,ny,cnt+1])

print(warp[Dh-1][Dw-1])
### BUGGY CODE ###

A, B, K = map(int,input().split())
if A <= 10**12 and B <= 10**12 and K <= 10**12:
  for _ in range(K):
    if A >= 1:
      A -= 1
    elif B >= 1:
      B -= 1
    else:
      break
print(A,B)

### FIXED CODE ###

a,b,c = map(int, input().split())
if a<=c:
    if b<=c-a:
        print('0 0')
    else:
        print('0 {}'.format(a+b-c))
else:
    print('{} {}'.format(a-c,b))
### BUGGY CODE ###

n=int(input())
A=list(input().split())
B=[]
import queue
q=queue.Queue()
for a in A:q.put(a)
while not q.empty():
    B.append(q.get())
    B.reverse()
print(" ".join(B))

### FIXED CODE ###

n = int(input())
a = list(input().split())
a1 = ['']*(n//2 + n%2)
a2 = ['']*(n//2)

for i in range(n):
	if i%2 == 0:
		a1[i//2] = a[i]
	else:
		a2[-i//2] = a[i]

if n%2 != 0 and n != 1:
	ans = ' '.join(a1[::-1]) + ' ' + ' '.join(a2[::-1])
elif n%2 == 0:
	ans = ' '.join(a2) + ' ' + ' '.join(a1)
else:
	ans = a[0]
print(ans)
### BUGGY CODE ###

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

from collections import deque

an = list(map(int, input().split()))

bn = list(map(int, input().split()))

an = [0] + an
bn = bn

vMax = 10**9+10

import itertools

accum_a = [0]
accum_b = [0]



candidate = []


for b_i in range(0,len(bn)):
    i_ = accum_b[-1] + bn[b_i]
    if i_ > k:
        break
    accum_b.append(i_)

accum_b.reverse()

countMax = 0
for a_i in range(0,len(an)):


    sumCandidate = accum_a[-1] + an[a_i]
    if sumCandidate > k:
        break
    accum_a.append(sumCandidate)

    rest = k - sumCandidate

    bIndex = 0
    for j, accB in enumerate(accum_b):
        if accB <= rest:
            bIndex = len(accum_b) - 1 - j
            break


    countMax = max(countMax, a_i + bIndex)



print(countMax)

### FIXED CODE ###

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

from collections import deque

an = list(map(int, input().split()))

bn = list(map(int, input().split()))

accum_a = [0]
accum_b = [0]


for a_i in range(0,len(an)):

    sumCandidate = accum_a[-1] + an[a_i]
    if sumCandidate > k:
        break
    accum_a.append(sumCandidate)

for b_i in range(0,len(bn)):
    i_ = accum_b[-1] + bn[b_i]
    if i_ > k:
        break
    accum_b.append(i_)

j = len(accum_b) - 1
ans = 0
for i in range(len(accum_a)):

    if accum_a[i] > k:
        break

    while accum_b[j] > k - accum_a[i]:
        j -= 1

    ans = max(ans, i+j)
print(ans)
### BUGGY CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
# dp[2] = min(abs(h[2]-h[0]), dp[1]+abs(h[2]-h[1]))
# dp[3] = min((abs(h[3]-h[1])+dp[1]), abs(h[3]-h[2])+dp[2])
for i in range(2,n):
    ans = 10000000000000000000000000
    for j in range(1,k+1):
        if i-j >= 0:
            tmp = abs(h[i]-h[i-j])+dp[i-j]
            ans = min(ans,tmp)
    # dp[i] = min((abs(h[i]-h[i-2])+dp[i-2]), abs(h[i]-h[i-1])+dp[i-1])
    dp[i] = ans
print(dp[-1])

### FIXED CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
# dp[2] = min(abs(h[2]-h[0]), dp[1]+abs(h[2]-h[1]))
# dp[3] = min((abs(h[3]-h[1])+dp[1]), abs(h[3]-h[2])+dp[2])
for i in range(2,n):
    ans = 10000000000000000000000000
    for j in range(1,k+1):
        if i-j >= 0:
            tmp = abs(h[i]-h[i-j])+dp[i-j]
            ans = min(ans,tmp)
    # dp[i] = min((abs(h[i]-h[i-2])+dp[i-2]), abs(h[i]-h[i-1])+dp[i-1])
    dp[i] = ans
print(dp[-1])
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
numbers = []
answers = []
for i in range(Q):
    numbers.append(list(map(int, input().split())))
    rice = S[numbers[i][0]-1:numbers[i][1]]
    answers.append(rice.count('AC'))
for answer in answers:
    print(answer)

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
data = [0] * (N+1)
for i in range(N):
    data[i+1] = data[i] + (1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
    l, r =map(int, input().split())
    print(data[r-1] - data[l-1])
### BUGGY CODE ###

h,n=map(int,input().split())
c=[list(map(int,input().split()))for _ in range(n)]
d=[0]+[10**9]*h
for i in range(h):
    #d[i]=min(d[i-a]+b for a,b in c)
    for a,b in c:
        a=min(a,h-i)
        d[i+a]=min(d[i+a],d[i]+b)
print(d[h])

### FIXED CODE ###

H,N=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(N)]
ab.sort()

ans=[10**9]*(H+1)
ans[0]=0
i=0
while i<=H:
    for a,b in ab:
        if a+i>H:
            a=H-i
        if ans[i+a]>ans[i]+b:
            ans[i+a]=ans[i]+b
    i+=1

print(ans[H])
### BUGGY CODE ###

#!/usr/bin/env python3
INF = float("inf")


def main():
    H, W, K = map(int, input().split())
    x1, y1, x2, y2 = map(int, input().split())
    W = W+2
    c = [["@"]*W]
    for i in range(H):
        c.append(["@"]+list(input())+["@"])
    c.append(["@"]*W)
    H = H+2

    DX = [1, 0, -1,  0]
    DY = [0, 1, 0, -1]

    # 方向付きで、ダイクストラ法を使います。
    dist = [[-1]*W for _ in range(H)]
    dist[x1][y1] = 0
    # ヒープでなくて良い。
    # 高々1しか加わっていかないため、キューに加えられた順で十分昇順になる。
    Q = [(0, x1, y1, 0)]
    Q += [(0, x1, y1, 1)]
    Q += [(0, x1, y1, 2)]
    Q += [(0, x1, y1, 3)]
    i = 0
    while i < len(Q):
        curr, x, y, DXY = Q[i]
        c[x][y] = "@"
        dx, dy = DX[DXY], DY[DXY]
        for k in range(1, K+1):
            X, Y = x+k*dx, y+k*dy
            if c[X][Y] == "@":
                break
            # if 0 < dist[X][Y] < curr+1:
            #     break
            # if dist[X][Y] == curr+1:
            #     continue
            dist[X][Y] = curr+1
            Q.append((curr+1, X, Y, (DXY+1) % 4))
            Q.append((curr+1, X, Y, (DXY-1) % 4))
        else:
            Q.append((curr+1, X, Y, DXY))
        if 0 < dist[x2][y2]:
            print(dist[x2][y2])
            return
        i += 1
    print(-1)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
INF = float("inf")


def main():
    H, W, K = map(int, input().split())
    x1, y1, x2, y2 = map(lambda x: int(x)-1, input().split())
    c = []
    for i in range(H):
        c.append(input())
    # 移動方法が4*K個考えられる無向グラフ
    # 到達可能性は最短経路を求めるだけでよい
    # 全ての箇所を探索するとO(H*W)必要に見える。
    # あれ、HW<=10^6がある。難しさは何？Kが大きいから枝が多すぎるということか。
    DX = [1, 0, -1,  0]
    DY = [0, 1, 0, -1]

    # 方向付きで、ダイクストラ法を使います。
    dist = [[-1]*W for _ in range(H)]
    dist[x1][y1] = 0
    Q = []                      # ヒープなんてもう知らない！
    M = 10**6
    Q.append((0, x1, y1, 0b1111))
    i = 0

    while i < len(Q):
        curr, x, y, DXY = Q[i]
        for j in range(4):
            if (DXY >> j) & 1 == 0:
                continue
            dx, dy = DX[j], DY[j]
            for k in range(1, K+1):
                X = x+k*dx
                Y = y+k*dy
                if not (0 <= X < H):
                    break
                if not (0 <= Y < W):
                    break
                if 0 < dist[X][Y] < curr+1:
                    break
                if dist[X][y] == curr+1:
                    continue
                if c[X][Y] == "@":
                    break
                dist[X][Y] = curr+1
                flag = (1 << ((j+1) % 4)) | (1 << ((j-1) % 4))
                if k != K:
                    Q.append((curr+1, X, Y, flag))
                else:
                    flag |= 1 << j % 4
                    Q.append((curr+1, X, Y, flag))
            if 0 < dist[x2][y2]:
                print(dist[x2][y2])
                return
        i += 1
    print(-1)
    return


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

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

class Transporter():
    def __init__(self, cap_out, temp=0):
        self.temp_num = temp
        self.cap_out = cap_out

    def transport(self):
        if self.temp_num < self.cap_out:
            num = self.temp_num
            self.temp_num = 0
            return num
        else:
            self.temp_num -= self.cap_out
            return self.cap_out

A_ = Transporter(A, temp=N)
B_ = Transporter(B)
C_ = Transporter(C)
D_ = Transporter(D)
E_ = Transporter(E)

time = 0
while (A_.temp_num!=0 or B_.temp_num!=0 or C_.temp_num!=0 or D_.temp_num!=0 or E_.temp_num!=0):
    time += 1
    a=A_.transport()
    b=B_.transport()
    c=C_.transport()
    d=D_.transport()
    e=E_.transport()
    B_.temp_num+=a
    C_.temp_num+=b
    D_.temp_num+=c
    E_.temp_num+=d

print(time)


### FIXED CODE ###

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

min_city = min([A, B, C, D, E])

print(4+(N+min_city-1)//min_city)
### BUGGY CODE ###

# encoding: "utf-8"

from collections import defaultdict

# class Stdin:
#     @staticmethod
#     def read_line(converter=str):
#         return [converter(x) for x in input().split()]
    
#     @staticmethod
#     def read_lines(n, converter=str):
#         result = list()
#         for _ in range(n):
#             result.append(Stdin.read_line(converter))
#         return result
    
#     @staticmethod
#     def convert(data, converter):
#         assert(len(data) == len(converter))
#         return tuple(map(lambda x, f: f(x), data, converter))

#     @staticmethod
#     def convert_lines(datas, n, converter):
#         return [converter(data, n, converter) for data in datas]


def first_count_and_pop(xs):
    cnt = 0
    fst = xs[0]
    # cnt = xs.count(fst)
    for x in xs:
        if x != fst:
            break
        cnt += 1
    return (cnt, xs[cnt:])    
    

def main():
    _ = input()
    # xs = Stdin.read_line(converter=int)
    xs = [int(x) for x in input().split()]
    xs.sort()
    ys = defaultdict(int)
    # for key in xs:
    #     ys[key] += 1
    #     ys[key-1] += 1
    #     ys[key+1] += 1
    while xs:
        key = xs[0]
        cnt = 1
        # for x in xs:
        #     if x != key:
        #         break
        #     cnt += 1
        cnt, xs = cnt, xs[cnt:]
        ys[key] += cnt
        ys[key-1] += cnt
        ys[key+1] += cnt

    print(max(ys.values()))

# def main_():
#     input()
#     xs = Stdin.read_line(converter=int)
#     xs.sort()
#     counts = list()
#     for i in range(100000):
#         if not xs:
#             counts.extend([0] * (100000 - len(counts)))
#             break     
#         elif i == xs[0]:
#             cnt, xs = first_count_and_pop(xs)
#             counts.append(cnt)
#         else:
#             counts.append(0)
#     m = 0
#     for i in range(0, 100000):
#         if i == 0:
#             temp = counts[i] + counts[i+1]
#         elif i == 100000 - 1:
#             temp = counts[i-1] + counts[i]
#         else:
#             temp = counts[i-1] + counts[i] + counts[i+1]
#         if m < temp:
#             m = temp
#     print(m)

if __name__ == "__main__":
    main()

### FIXED CODE ###

input()
a_list = [int(s) for s in input().split()]

count = [0]*100002

for a in a_list:
    count[a] += 1
    count[a+1] += 1
    count[a+2] += 1
    
print(max(count))
### BUGGY CODE ###

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

ans=0
for i in range(N):
  flag=0
  for j in range(N):
    if i==j:
      continue
    if A[j] > A[i]:
      break
    if A[i]%A[j]==0:
      flag=1
      break
  if flag==0:
    ans+=1
print(ans)


### FIXED CODE ###

#https://at274.hatenablog.com/entry/2020/06/29/181102
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
A=set(A)
MAX_A=10**6
X=[0]*(MAX_A + 1)#0-MAX_Aまでの整数がAの倍数で何回割られるか
for i in A:
  for j in range(i,MAX_A + 1,i):
    X[j]+=1

#割られた回数が1つしかないものはその数自身で割ったのでカウント
#ただし複数ある場合は除外
ans = len([a for a in A if (X[a] == 1) and (c[a] == 1)])
print(ans)
### BUGGY CODE ###

N,C = map(int,input().split())
D = [list(map(int,input().split())) for i in range(C)]
c = [list(map(int,input().split())) for i in range(N)]
m = N*N*(10**3)
for i in range(C):
  for j in range(C):
    for k in range(C):
      s = m
      if i!=j and j!=k and k!=i:
        s = 0
        for x in range(N):
          for y in range(N):
            if (x+y)%3 == 0:
              s += D[c[x][y]-1][i]
            elif (x+y)%3 == 1:
              s += D[c[x][y]-1][j]
            else:
              s += D[c[x][y]-1][k]
        if s < m:
          m = s
print(m)

### FIXED CODE ###

import collections
N,C = map(int,input().split())
D = [list(map(int,input().split())) for i in range(C)]
c = [list(map(int,input().split())) for i in range(N)]
c0 = []; c1 = []; c2 = []
for x in range(N):
    for y in range(N):
        if (x+y)%3 == 0:
            c0.append(c[x][y])
        elif (x+y)%3 == 1:
            c1.append(c[x][y])
        else:
            c2.append(c[x][y])
cnt0 = collections.Counter(c0)
cnt1 = collections.Counter(c1)
cnt2 = collections.Counter(c2)
m = N*N*1000
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i==j or j==k or k==i:
                s = N*N*1000
            else:
                s = 0
                for n in range(C):
                  s += D[n][i]*cnt0[n+1] + D[n][j]*cnt1[n+1] + D[n][k]*cnt2[n+1]
            if s < m:
                m = s
print(m)
### BUGGY CODE ###

from collections import deque

N, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]

memo = {}
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a].append(b)
    E[b].append(a)
    memo[(a, b)] = i
    memo[(b, a)] = i

K = max(len(e) for e in E)

A = [0] * (N - 1)

cand = {i for i in range(1, K + 1)}

visited = [False] * (N + 1)

Q = deque([(-1, 1)])
visited[1] = True
while Q:
    c, v = Q.popleft()
    C = cand - {c}
    for u in E[v]:
        if visited[u]:
            continue
        visited[u] = True
        c = C.pop()
        Q.append((c, u))
        A[memo[(v, u)]] = c

print(K)
for a in A:
    print(a)


### FIXED CODE ###

from collections import deque

def main():
    N, *AB = map(int, open(0).read().split())

    E = [set() for _ in range(N + 1)]

    memo = {}
    for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
        E[a].add(b)
        E[b].add(a)
        memo[(a, b)] = i
        memo[(b, a)] = i

    K = max(len(e) for e in E)

    A = [""] * (N - 1)

    visited = [False] * (N + 1)

    Q = deque([(-1, 1)])
    visited[1] = True
    while Q:
        a, v = Q.popleft()
        c = 0
        for u in E[v]:
            E[u].remove(v)
            c += 1
            if c == a:
                c += 1
            Q.append((c, u))
            A[memo[(v, u)]] = str(c)
        E[v] = set()
    print(K)
    print("\n".join(A))

main()
### BUGGY CODE ###

from scipy.special import comb
n=int(input())
a=list(map(int,input().split()))

l=[0]*(n+1)
tmp=0
for i in range(0,n):
  l[i+1]=tmp+a[i]
  tmp=l[i+1]
#print(l)

s=set(l)
ans=0
for i in s:
  ans+=comb(l.count(i), 2, exact=True)
print(ans)

### FIXED CODE ###

from scipy.special import comb
from collections import Counter as C
n=int(input())
a=list(map(int,input().split()))

l=[0]*(n+1)
tmp=0
for i in range(0,n):
  l[i+1]=tmp+a[i]
  tmp=l[i+1]

c=C(l)
ans=0

for v in c.values():
  ans+=comb(v, 2, exact=True)
print(ans)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

ans = 0
for i in range(1000):
	i = str(i).zfill(3)
	pat = "{}.*{}.*{}".format(i[0], i[1], i[2])
	if re.search(pat, S):
		ans += 1
print(ans)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = input()
S = input()

s = set([""])
for n in S[::-1]:
	s |= set(x+n for x in s if len(x) != 3)

print(len([x for x in s if len(x) == 3]))
### BUGGY CODE ###

N, M = [int(i) for i in input().split()]
data = list()
sorted_data = dict()
for i in range(M):
    p, y = [int(i) for i in input().split()]
    data.append([p, y])
    if sorted_data.get(p) is None:
        sorted_data[p] = []
    sorted_data[p].append(y)
sorted_data = {i: sorted(j) for i, j in sorted_data.items()}

for i in range(M):
    rank = sorted_data[data[i][0]].index(data[i][1]) + 1
    print(str(data[i][0]).zfill(6) + str(rank).zfill(6))

### FIXED CODE ###

N, M = [int(i) for i in input().split()]
data = list()
for i in range(M):
    p, y = [int(i) for i in input().split()]
    data.append([i, p, y])
data.sort(key=lambda x:(x[1],x[2]))
ind = 1
for j, (i, p, y) in enumerate(data):
    if data[j-1][1] != p:
        ind = 1
    data[j].append(ind)
    ind += 1
data.sort(key=lambda x:x[0])
for i, p, y, j in data:
    print(str(p).zfill(6) + str(j).zfill(6))
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
flg = 0
for i in range(q):
    l, r = map(int, input().split())
    cnt = 0
    for i in range(l-1, r):
        if s[i] == 'A':
            flg = 1
        elif s[i] == 'C' and flg == 1:
            cnt += 1
            flg = 0
        else:
            flg =0
    print(cnt)


### FIXED CODE ###

n, q = map(int, input().split())
s = input()
flg = 0

ac_list = [0]

for i in range(0, len(s)-1):
    if s[i] == 'A' and s[i+1] == 'C':
        ac_list.append(ac_list[i]+1)
    else:
        ac_list.append(ac_list[i])

#print(ac_list)

for i in range(q):
    l, r = map(int, input().split())
    print(ac_list[r-1] - ac_list[l-1])