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

n,x,y = map(int,input().split())
x -= 1
y -= 1
dis = [[0 for i in range(n)]for j in range(n)]
for i in range(n):
    for j in range(i+1,n):
        dis[i][j] = min(abs(j-i),min(abs(j-y)+abs(x-i)+1,abs(j-x)+abs(y-i)+1))
d = [0 for i in range(n)]
for i in range(n):
    for j in range(n):
        d[dis[i][j]] += 1
print("\n".join(map(str,d[1:])))

### FIXED CODE ###

n,x,y = map(int,input().split())
x -= 1
y -= 1
dis = [0 for i in range(n)]
for i in range(n):
    for j in range(i+1,n):
        dis[min(abs(j-i),min(abs(j-y)+abs(x-i)+1,abs(j-x)+abs(y-i)+1))] += 1
print("\n".join(map(str,dis[1:])))
### BUGGY CODE ###

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

A = 0

for i in range(N):
  B = 0
  for j in range(i+1):
    if P[i] <= P[j]:
      B += 1
  if B == i + 1:
    A += 1
print(A)
  

### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
 
A = 0
C = P[0]
for i in range(N):
  if P[i] <= C:
    C = P[i]
    A += 1
print(A)
### BUGGY CODE ###

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

P = list(map(lambda x:x-1, P))

ans = -float('inf')
for si in range(N):
    s = []
    tot = 0
    x = si
    while True:
        x = P[x]
        s.append(C[x])
        tot += C[x]
        if x==si:
            break
    l = len(s)
    now = 0
    t = 0
    for i in range(l):
        if i+1 > K: break
        t += s[i]
        now = t
        if tot >0:
            e = (K-(i+1))//l
            now += tot * e
        ans = max(ans, now)


print(ans)




### FIXED CODE ###

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

P = list(map(lambda x:x-1, P))

ans = -float('inf')
for si in range(N):
    s = []
    tot = 0
    x = si
    while True:
        x = P[x]
        s.append(C[x])
        tot += C[x]
        if x==si:
            break
    l = len(s)
    now = 0
    t = 0
    for i in range(l):
        if i+1 > K: break
        t += s[i]
        now = t
        if tot >0:
            e = (K-(i+1))//l
            now += tot * e
        ans = max(ans, now)


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

def main():
    n, a = map(int, input().split())
    x = list(map(int, input().split()))

    ans = 0
    for pat in range(1, 1 << n):
        cnt = 0
        sm = 0
        i = 0
        while pat:
            if pat % 2:
                cnt += 1
                sm += x[i]
            pat //= 2
            i += 1

        if sm / cnt == a:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline


def main():
    n, a = map(int, input().split())
    x = tuple(map(int, input().split()))

    sm_mx = sum(x)

    dp = [[[0] * (sm_mx + 1) for _ in range(n + 1)] for _ in range(n + 1)]

    dp[0][0][0] = 1

    for i, e in enumerate(x, 1):
        for j in range(n + 1):
            for sm in range(sum(x[:i]) + 1):
                if sm < e:
                    dp[i][j][sm] = dp[i-1][j][sm]
                elif j >= 1 and sm >= e:
                    dp[i][j][sm] = dp[i-1][j][sm] + dp[i-1][j-1][sm-e]

    ans = 0
    for i in range(1, n + 1):
        if i > sm_mx / a:
            break
        ans += dp[n][i][i*a]

    print(ans)


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

N,P=map(int,input().split(' '))
S =input()
ans = 0
cnt = [0]*P
cnt[0]=1
for i in range(N):
    cnt[int(S[i:])%P] += 1
if P==2 or P==5:
    if P==2:
        check=[0,2,4,6,8]
    else:
        check=[0,5]
    for n,i in enumerate(S[::-1]):
        if int(i) in check:
            ans += N-n
else:
    for i in cnt:
        ans += i*(i-1)//2
print(ans)

### FIXED CODE ###

N,P=map(int,input().split(' '))
S =list(map(int,list(input()[::-1])))
ans = 0
cnt = [0]*P
cnt[0]=1
tmp = 0
for n,i in enumerate(S):
    d=i*pow(10,n,P)
    tmp =(tmp+d)%P
    cnt[tmp] += 1
if P in [2,5]:
    if P==2:
        check=[0,2,4,6,8]
    else:
        check=[0,5]
    for n,i in enumerate(S):
        if i in check:
            ans += N-n
else:
    for i in cnt:
        ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

N,k = map(int,input().split())
a = list(map(int,input().split()))
i = 0
while i < N:
    if a[i] >= 0:
        break
    i += 1
x = []
y = []
for j in range(i-k,i+1):
    if j>=0 and j+k-1<N:
        x = a[j:j+k]
        if x[0] < 0 and x[k-1] > 0:
            y.append(min(-x[0],x[k-1])*2 + max(-x[0],x[k-1]))
        else:
            y.append(max(-x[0],x[k-1]))
print(min(y))

### FIXED CODE ###

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

if 0 in x:
    K -= 1

cand = []
hasleft = x[0] < 0
hasright = x[N-1] > 0
if K == 0:
    cand = [0]
else:
    for i in range(N-K+1):
        left = x[i]
        right = x[i+K-1]
        if left < 0 and right > 0:
            cand.append(min(abs(left)*2+right, right*2+abs(left)))
        elif right < 0:
            cand.append(abs(left))
        elif left > 0:
            cand.append(right)
print(min(cand))
### BUGGY CODE ###

N,K = map(int,input().rstrip().split(" "))
A = [list(map(int,input().rstrip().split(" ")))]
imos = [0 for i in range(N + 1)]
P = 0
flag = True
counter = 0
while flag:
    A.append([0 for i in range(N)])
    P = 0
    for i in range(N+1):
        imos[i] = 0
    for i in range(N):
        imos[max(0,i - A[counter][i])] += 1
        imos[min(N,i + A[counter][i] + 1)] -= 1
    if imos[0] == N and imos[N] == -1 * N:
        flag = False
    for i in range(N):
        P += imos[i]
        A[counter + 1][i] = P
    counter += 1
    if counter == K:
        break
print(" ".join(map(str,A[-1])))

### FIXED CODE ###

N,K = map(int,input().rstrip().split(" "))
A = [list(map(int,input().rstrip().split(" ")))]
imos = [0 for i in range(N + 1)]
P = 0
flag = True
counter = 0
while flag:
    A.append([0 for i in range(N)])
    P = 0
    for i in range(N+1):
        imos[i] = 0
    for i in range(N):
        imos[max(0,i - A[counter][i])] += 1
        imos[min(N,i + A[counter][i] + 1)] -= 1
    if imos[0] == N and imos[N] == -1 * N:
        flag = False
    for i in range(N):
        P += imos[i]
        A[counter + 1][i] = P
    counter += 1
    if counter == K:
        break
print(" ".join(map(str,A[-1])))
### BUGGY CODE ###

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

for i in range(M):
    A = sorted(A,reverse=True)
    A[0] = A[0]//2
print(sum(A))

### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
A = list(map(lambda x: x*(-1),A))
import heapq
heapq.heapify(A)

for i in range(M):
    maxA = (((heapq.heappop(A))*(-1))//2)*(-1)
    heapq.heappush(A,maxA)
   
    
print(sum(A)*-1)
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort(reverse=True)
hi=10**12
lo=0
def c(mi):
    tmp=0
    for i,j in zip(a,f):
        if mi//j<i:
            tmp+=i-mi//j
    if tmp<=k:
        return True
    return False
while hi>=lo:
    mi=(hi+lo)//2
    if c(mi):
        hi=mi-1
    else:
        lo=mi+1
print(lo)

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort(reverse=True)
hi=10**12
lo=0
def c(mi):
    tmp=0
    for i,j in zip(a,f):
        if mi//j<i:
            tmp+=i-mi//j
    if tmp<=k:
        return True
    return False
while hi>=lo:
    mi=(hi+lo)//2
    if c(mi):
        hi=mi-1
    else:
        lo=mi+1
print(lo)
### BUGGY CODE ###

N = int(input())
k = list(map(int,input().split()))
counter = 0
for i in range(N):
    for l in range(i):
        if i-l== k[i]+k[l]:
            counter+=1
print(counter)

### FIXED CODE ###

N = int(input())

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



li = [[0]*N,[0]*N ]

for index,a in enumerate(A):
    li[0][index] = a- index
    li[1][index]= -a - index


from collections import Counter


cou_one = Counter(li[0])
cou_two = Counter(li[1])




counter = 0
for key,value in cou_one.items():
    counter += cou_two[key]*value


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

line = input().split(sep=" ")
x = int(line[0])
y = int(line[1])
z = int(line[2])
in_k = int(line[3])


in_x = sorted(list(map(int,input().split(sep=" "))))
in_y = sorted(list(map(int,input().split(sep=" "))))
in_z = sorted(list(map(int,input().split(sep=" "))))

ans_arr = []

if(x > in_k ): x =in_k
if(y > in_k ): y =in_k
if(z > in_k ): z =in_k

for i in range(x):
	for j in range(y):
		for k in range(z):
			ans_arr.append(in_x[i] + in_y[j] + in_z[k])

ans_arr = sorted(ans_arr,reverse=True)

for i in range(in_k):
	print(ans_arr[i])


### FIXED CODE ###

X, Y, Z, K = map(int, input().split())

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


A = sorted(A, key = lambda x:-x)
B = sorted(B, key = lambda x:-x)
C = sorted(C, key = lambda x:-x)

AB = [0] * (X * Y)

ABC = []

for i in range(X):
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break
        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            ABC.append(A[i] + B[j] + C[k])

ABC = sorted(ABC, key = lambda x:-x)
for i in range(0, K):
    print(ABC[i])
### BUGGY CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
L=[]
for i in range(m):
    bc=list(map(int,input().split()))
    L.append(bc)
L=sorted(L,key=lambda x:x[1],reverse=True)

import bisect
for l in L:
    if a[0]>=l[1]:
        break
    ind=bisect.bisect_left(a,l[1])
    ind=min(ind,l[0])
    for i in range(ind):
        a[i]=l[1]
    a=sorted(a)
print(sum(a))

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
L=[]
for i in range(m):
    bc=list(map(int,input().split()))
    L.append(bc)
L=sorted(L,key=lambda x:x[1],reverse=True)

import bisect
star=0
ans=0
for l in L:
    ind=bisect.bisect_left(a,l[1],star,n)
    if ind>star+l[0]:
        star += l[0]
        ans += l[0]*l[1]
    else:
        ans += (ind-star)*l[1]
        star=ind
        break
ans += sum(a[star:n])
    
print(ans)
### BUGGY CODE ###

l=list(input())
c=0
while "1" in l and "0" in l:
  for i in range(1,len(l)):
    if (l[i-1]=="0" and l[i]=="1") or (l[i-1]=="1" and l[i]=="0"):
      del l[i-1]
      del l[i-1]
      c+=2
      break
print(c)
      

### FIXED CODE ###

s=list(input())
c1=0
c2=0
for i in range(len(s)):
  if s[i]=="1":
    c1+=1               
  else:
    c2+=1
print(2*min(c1,c2))
### BUGGY CODE ###

import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def reverse(S):
    return S[::-1]

def main():
    S = _S()
    Q = I()
    Querys = [LS() for _ in range(Q)]
    s = S
    rev_flg = -1
    for q in Querys:
        # print(q)
        if q[0]=='1':
            rev_flg *= -1
            # s = reverse(s)
        elif q[0]=='2':
            ti,fi,ci = q
            # print(ti,fi,ci)
            # print(int(fi)*rev_flg)
            if int(fi)*rev_flg in (1,-2):
                s = s+ci
            elif int(fi)*rev_flg in (-1,2):
                s = ci+s
            else:
                pass
        else:
            pass
    print(s[::-1] if rev_flg==1 else s)

main()



### FIXED CODE ###

import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    S = _S()
    Q = I()
    Querys = [LS() for _ in range(Q)]
    rev_flg = -1
    dq = collections.deque(S)
    for q in Querys:
        if q[0]=='1':
            rev_flg *= -1
        else:
            ti,fi,ci = q
            if int(fi)*rev_flg in (1,-2):
                dq.append(ci)
            else:
                dq.appendleft(ci)

    print("".join(dq)[::-1] if rev_flg==1 else "".join(dq))

main()
### BUGGY CODE ###

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

P = [K for _ in range(N)]
for _ in range(Q):
    A = int(input()) - 1
    P = [p - 1 if A != i  else p for i, p in enumerate(P)]

for x in P:
    if x <= 0:
        print('No')
    else:
        print('Yes')

### FIXED CODE ###

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

P = [K for _ in range(N)]
D = []
for _ in range(Q):
    A = int(input()) - 1
    P[A] += 1

for x in P:
    if Q + 1 <= x:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
#mod_a = [i%(10**9 + 7) for i in a]
res = 0
for i in range(0, len(a)-1):
  for j in range(i+1, len(a)):
    res += (a[i]*a[j])%(10**9 + 7)
print(res%(10**9 + 7))



### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
#mod_a = [i%(10**9 + 7) for i in a]
res = 0
sum_a = sum(a)
b = 0
t = 0
for i in range(0, len(a)-1):
  t = a[i]
  b += a[i]
  res += (sum_a - b)*t%(10**9 + 7)
print(res%(10**9 + 7))
### BUGGY CODE ###

n,q = map(int,input().split())
s = input()
z = [list(map(int,input().split())) for i in range(q)]
l,r = [list(i) for i in zip(*z)]

for i in range(q):
    print(s[l[i]-1:r[i]].count('AC'))

### FIXED CODE ###

n,q = map(int,input().split())
s = input()
s = s.replace('AC','ac')
t = [0] * n
r = 0
for i in range(n):
    if s[i] == 'c':
        r += 1
    t[i] = r
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])
### BUGGY CODE ###

# AtCoder Educational DP Contest
# B Frog 2


def main():
    n, k, *h = map(int, open(0).read().split())

    DP = [0 for _ in range(n)]
    for i, h_now in enumerate(h[1:], 1):
        l = max(0, i - k)
        hs = h[l:i]
        DPs = DP[l:i]
        tmp = []
        for x, y in zip(hs, DPs):
            cost = abs(h_now - x) + y
            tmp.append(cost)
        DP[i] = min(tmp)

    res = DP[-1]
    print(res)


if __name__ == '__main__':
    main()


### FIXED CODE ###

n, k = map(int, input().split())
hs = list(map(int, input().split()))
dp=[0]*n
dp[0]=0
for i, hi in enumerate(hs):
    if i == 0:
        continue
    s = max(0, i-k)
    dp[i] = min([ml + abs(hl - hi) for ml, hl in zip(dp[s:i], hs[s:i])])
print(dp[-1])
### BUGGY CODE ###

def renew(lis,id1,id2):
  tar = lis[id1]; bow = lis[id2]
  if tar[0] < bow[0]:
    tar = [bow[0],max(bow[1],tar[0])]
  else:
    tar[1] = max(bow[0],tar[1])
  lis[id1] = tar
  return

n = int(input())
a = [[x,0] for x in list(map(int, input().split()))]
for j in range(n):
  for i in range(2**n):
    if not i & (1<<j):
      renew(a,i|(1<<j),i)
a = [x+y for x,y in a[1:]]
for i in range(1,2**n-1):
  if a[i] < a[i-1]:
    a[i] = a[i-1]
for x in a:
  print(x)


### FIXED CODE ###

def renew(lis,id1,id2):
  tar = lis[id1]; bow = lis[id2]
  if tar[0] < bow[0]:
    tar = [bow[0],max(bow[1],tar[0])]
  else:
    tar[1] = max(bow[0],tar[1])
  lis[id1] = tar
  return

n = int(input())
a = [[x,0] for x in list(map(int, input().split()))]
for j in range(n):
  for i in range(2**n):
    if not i & (1<<j):
      renew(a,i|(1<<j),i)
a = [x+y for x,y in a[1:]]
for i in range(1,2**n-1):
  if a[i] < a[i-1]:
    a[i] = a[i-1]
for x in a:
  print(x)
### BUGGY CODE ###

import heapq

# dijkstra shortest path solver
def min_cost(G, s, n):
    inf = float("inf")
    cost = [inf for _ in range(n)]
    cost[s] = 0
    q = list()
    heapq.heappush(q, (0, s))

    while q:
        w,index = heapq.heappop(q)
        if cost[index] < w:
            continue
        for j in G[index]:
            c = cost[index] + G[index][j]
            if c < cost[j]:
                cost[j] = c
                heapq.heappush(q, (c, j))
    return cost

if __name__ == '__main__':
    money = 10**15

    # read inputs
    n, m, s, t = list(map(int,input().split()))
    # zero origin
    S = s-1
    T = t-1

    # create empty graph
    G = [{} for _ in range(n)] # JPY
    H = [{} for _ in range(n)] # SNK

    # set virtex with weight
    for i in range(m):
        u, v, p, q = list(map(int, input().split()))
        u -= 1
        v -= 1
        G[u][v] = p
        G[v][u] = p
        H[u][v] = q
        H[v][u] = q

    min_jpy = min_cost(G, S, n)
    min_snk = min_cost(H, T, n)
    total = [x+y for (x, y) in zip(min_jpy, min_snk)]
    for year in range(n):
        for i in range(year, n):
            cost = min(total[year:])

        print(money - cost)

### FIXED CODE ###

import heapq
from itertools import accumulate

# dijkstra shortest path solver
def min_cost(G, s, n):
    inf = float("inf")
    cost = [inf for _ in range(n)]
    cost[s] = 0
    q = list()
    heapq.heappush(q, (0, s))

    while (len(q) != 0):
    #while q:
        w,index = heapq.heappop(q)
        if cost[index] < w:
            continue
        for j in G[index]:
            c = cost[index] + G[index][j]
            if c < cost[j]:
                cost[j] = c
                heapq.heappush(q, (c, j))
    return cost

if __name__ == '__main__':
    money = 10**15

    # read inputs
    n, m, s, t = list(map(int,input().split()))
    # zero origin
    S = s-1
    T = t-1

    # create empty graph
    G = [{} for _ in range(n)] # JPY
    H = [{} for _ in range(n)] # SNK

    # set virtex with weight
    for i in range(m):
        u, v, p, q = list(map(int, input().split()))
        u -= 1
        v -= 1
        G[u][v] = p
        G[v][u] = p
        H[u][v] = q
        H[v][u] = q

    min_jpy = min_cost(G, S, n)
    min_snk = min_cost(H, T, n)
    total = [x+y for (x, y) in zip(min_jpy, min_snk)]
    # pre calc minimum cost for all year
    fl = list(accumulate(total[::-1], min))[::-1]

    for year in range(n):
        print(money - fl[year])
### BUGGY CODE ###

S=input()
S_list=[]
for k in range(len(S)):
    S_list.append(S[k])
Q=int(input())
kouho=[]
for i in range(Q):
    kari=input().split()
    kouho.append(kari)
for j in range(len(kouho)):
    if kouho[j][0]=="1":
        S_list.reverse()
    else:
        if kouho[j][1]=="1":
            S_list=[kouho[j][2]]+S_list
        else:
            S_list.append(kouho[j][2])
print(*S_list,sep="")

### FIXED CODE ###

from collections import deque
S=input()
S_list=deque()
for k in range(len(S)):
    S_list.append(S[k])
Q=int(input())
kouho=[input().split() for i in range(Q)]
"""for i in range(Q):
    kari=input().split()
    kouho.append(kari)"""
hanten=[]
count=0
flaag=["sonomama","hantai"]

for j in range(Q):
    flag=flaag[count%2]
    if kouho[j][0]=="1":
        count+=1
    else:
        if flag=="sonomama":
            if kouho[j][1]=="1":
                S_list.appendleft(kouho[j][2])
            else:
                S_list.append(kouho[j][2])
        else:
            if kouho[j][1]!="1":
                S_list.appendleft(kouho[j][2])
            else:
                S_list.append(kouho[j][2])
for k in range(count%2):
    S_list.reverse()
print(*S_list,sep="")
### BUGGY CODE ###

def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    #n, m = int(input())
    # 整数複数個
    n, m = map(int, input().split())
    # 整数 N 個 (改行区切り)
    A = [int(input()) for i in range(m)]
    # 整数 N 個 (スペース区切り)
    #A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    Route = [0] * (n+1)
    Route[0] = 1
    if 1 not in A:
        Route[1] = 1
    MOD = 10**9 + 7
    for i in range(2, n+1):
        if i not in A:
            Route[i] = (Route[i-1] + Route[i-2]) % MOD
#            Route[i] %= MOD

    print(Route[n])
#    print(Route)
resolve()

### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, M = map(int, input().split())
    A = [int(input()) for _ in range(M)]
    is_safe = [True] * (N+2)
    for a in A:
        is_safe[a+1] = False

    dp = [0] * (N+2)
    dp[1] = 1
    for i in range(2, N+2):
        if is_safe[i]:
            dp[i] = dp[i-1] + dp[i-2]
            dp[i] %= MOD
        else:
            dp[i] = 0

    return dp[N+1]


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

S=input()
L=len(S)
children={}

for i in range(L):
    children[i]=0

for i in range(L):
    count=0
    d=S[i]
    if d=='R':
        j=1
        while(1):
            if S[i+j]==d:
                count+=1
                j=j+1
                continue
            else:
                if j%2==0:
                    children[i+j]+=1
                else:
                    children[i+j-1]+=1
                break
    if d=='L':
        j=1
        while(1):
            if S[i-j]==d:
                count+=1
                j=j+1
                continue
            else:
                if j%2==0:
                    children[i-j]+=1
                else:
                    children[i-j+1]+=1
                break
    #print(children[i])

s=''
for i in range(L):
    s+=str(children[i])+' '
print(s.rstrip())

### FIXED CODE ###

S=input()

num={}
for i in range(len(S)):
    num[i]=0

for i in range(1,len(S)):
    even=1
    odd=1
    if S[i]=='L' and S[i-1]=='R':

        j=1
        while(1):
            if i+j>(len(S)-1):
                break
            if S[i+j]=='L':
                if j%2==1:
                    odd+=1
                else:
                    even+=1
            else:
                break
            j+=1
        
        j=1
        while(1):
            if i-1-j<0:
                break
            if S[i-1-j]=='R':
                if j%2==1:
                    even+=1
                else:
                    odd+=1
            else:
                break
            j+=1

        num[i]=even
        num[i-1]=odd

for i in range(len(S)):
    print(num[i],end=' ')
print('')
### BUGGY CODE ###

import math

k = int(input())
ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            ans += math.gcd(math.gcd(a, b), c)

print(ans)


### FIXED CODE ###

from math import gcd

K = int(input())
ans = 0
for i in range(1, K + 1):
    ans += i
for i in range(1, K + 1):
    for j in range(i + 1, K + 1):
        ans += gcd(i, j) * 6

for i in range(1, K - 1):
    for j in range(i + 1, K):
        for k in range(j + 1, K + 1):
            ans += gcd(gcd(i, j), k) * 6

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

import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    S = input()
    cnt = 0
    for i in range(1000):
        ptn = str(i).zfill(3)
        j = 0
        flg = 0
        while j < N:
            if S[j] == ptn[flg]:
                flg += 1
                if flg == 3:
                    cnt += 1
                    break
            j += 1
    print(cnt)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    S = input()
    cnt = 0
    for i in range(1000):
        ptn = str(i).zfill(3)
        j = 0
        flg = 0
        while j < N:
            if S[j] == ptn[flg]:
                flg += 1
                if flg == 3:
                    cnt += 1
                    break
            j += 1
    print(cnt)


if __name__ == '__main__':
    main()