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

def main():
    X = input()
    count = 0
    for i in range(10**6):
        count += X.count("ST")
        X = X.replace("ST","")
    print(len(X))


if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import deque
def main():
    X = input()
    stack = deque([])
    for i in range(len(X)):
        if X[i] == "S":
            stack.append(X[i])
        else:
            if len(stack) != 0:
                tmp = stack.pop()
                if tmp == "T":
                    stack.append(tmp)
                    stack.append(X[i])
            else:
                stack.append(X[i])
    print(len(stack))
if __name__ == '__main__':
    main()
### BUGGY CODE ###

S = input()
MOD = 10**9 + 7
lenS = len(S)

dp = [[0 for _ in range(13)] for _ in range(lenS + 1)]  # dp[digit][d] = digit桁までの mod=d の数
dp[0][0] = 1

digitMask = 1

for digit in range(1, lenS + 1) :
    if(S[-digit] == '?') :
        for d in range(13) :
            for k in range(10) :
                dp[digit][d] = (dp[digit][d] + dp[digit - 1][(d - k * digitMask) % 13]) % MOD
    else :
        a = int(S[-digit])
        for d in range(13) :
            dp[digit][d] = (dp[digit][d] + dp[digit - 1][(d - a * digitMask) % 13]) % MOD
    digitMask *= 10
    digitMask %= 13

ans = (dp[len(S)][5]) % MOD
print(ans)



### FIXED CODE ###

S = input()
MOD = 10**9 + 7
lenS = len(S)

dp = [[0 for _ in range(13)] for _ in range(lenS + 1)]  # dp[digit][d] = digit桁までの mod=d の数
dp[0][0] = 1

digitMask = 1

for digit in range(1, lenS + 1) :
    if(S[-digit] == '?') :
        for d in range(13) :
            for k in range(10) :
                dp[digit][d] = (dp[digit][d] + dp[digit - 1][(d - k * digitMask) % 13]) % MOD
    else :
        a = int(S[-digit])
        for d in range(13) :
            dp[digit][d] = (dp[digit][d] + dp[digit - 1][(d - a * digitMask) % 13]) % MOD
    digitMask *= 10
    digitMask %= 13

ans = (dp[len(S)][5]) % MOD
print(ans)
### BUGGY CODE ###

N,K=map(int,input().split())
x=[int(i) for i in input().split()]
cost=[]

for i in range(N-K+1):
	length=0
	for j in range(K-1):
		length+=abs(x[i+j+1]-x[i+j])
	cost.append(length+abs(x[i]))
	cost.append(length+abs(x[i+K-1]))
print(min(cost))

### FIXED CODE ###

N,K=map(int,input().split())
x=[int(i) for i in input().split()]
cost=[]

for i in range(N-K+1):
	length=abs(x[i]-x[i+K-1])
	cost.append(length+abs(x[i]))
	cost.append(length+abs(x[i+K-1]))
print(min(cost))
### BUGGY CODE ###

import collections
import math

#****************************************************************
def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
#****************************************************************

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

c = collections.Counter(A)
dict_ans = {}

for i in c.keys():
    target = c.copy()
    target[i] -= 1
    ans = 0
    for k in target.values():
        ans += comb(k, 2)
    dict_ans[i] = ans

for i in A:
    print(dict_ans[i])


### FIXED CODE ###

import collections
import math

#****************************************************************
def comb(n):
    if n < 2:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
#****************************************************************

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

c = collections.Counter(A)
full_ans = sum(list(map(comb, c.values())))

for a in A:
    print(full_ans - c[a] + 1)
### BUGGY CODE ###

H,W = input().split()
H,W = int(H),int(W)
MP = []
for i in range(10):
    MP.append(list(map(int,input().split())))

board = []
for h in range(H):
    board.append(list(map(int,input().split())))

def mincost(start,goal):
    queue = []
    queue.append((start,[],0))
    queue[0][1].append(start)
    mincost = 99999999999999999999999999999
    while len(queue) != 0:
        q = queue.pop(0)
        if q[0] == goal:
            if q[2] < mincost:
                mincost = q[2]
        else:
            for i in range(10):
                if i not in q[1]:
                    tq = q[1].copy()
                    tq.append(i)
                    if q[2]+MP[q[0]][i] < mincost:
                        queue.append((i,tq,q[2]+MP[q[0]][i]))
    return mincost

need_magical_power = 0
for h in range(H):
    for w in range(W):
        if board[h][w] == -1 or board[h][w] == 1:
            pass
        else:
            need_magical_power += mincost(board[h][w],1)

print(need_magical_power)


### FIXED CODE ###

H,W = input().split()
H,W = int(H),int(W)
MP = []
for i in range(10):
    MP.append(list(map(int,input().split())))

board = []
for h in range(H):
    board.append(list(map(int,input().split())))

def mincost(start,goal):
    queue = []
    queue.append((start,[],0))
    queue[0][1].append(start)
    mincost = 99999999999999999999999999999
    while len(queue) != 0:
        q = queue.pop(0)
        if q[0] == goal:
            if q[2] < mincost:
                mincost = q[2]
        else:
            for i in range(10):
                if i not in q[1]:
                    tq = q[1].copy()
                    tq.append(i)
                    if q[2]+MP[q[0]][i] < mincost:
                        queue.append((i,tq,q[2]+MP[q[0]][i]))
    return mincost

need_magical_power = 0
mincost_list = []
for i in range(10):
    mincost_list.append(mincost(i,1))


for h in range(H):
    for w in range(W):
        if board[h][w] == -1 or board[h][w] == 1:
            pass
        else:
            need_magical_power += mincost_list[board[h][w]]

print(need_magical_power)
### BUGGY CODE ###

import sys
import itertools
 
N = int(input())
L = [int(v) for v in sys.stdin.readline().split()]

print(len([0 for a, b, c in itertools.combinations(L, 3) if a + b > c and b + c > a and a + c > b]))


### FIXED CODE ###

import sys
from bisect import bisect_left

N = int(input())
A = [int(v) for v in sys.stdin.readline().split()]

A = sorted(A)

cnt = 0
for i in range(N - 2):
    for j in range(i+1, N - 1):
        ij = A[i] + A[j]
        cnt += bisect_left(A, ij) - (j + 1)
print(cnt)
### BUGGY CODE ###

N, M, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

max_cnt = 0
for i in range(N+1):
    for j in range(M+1):
        a, b = A[:i], B[:j]
        total = sum(a) + sum(b)
        if total <= K:
            cnt = len(a) + len(b)
            max_cnt = max(max_cnt, cnt)

print(max_cnt)

### FIXED CODE ###

from itertools import accumulate

N, M, K = map(int, input().split())
A = list(accumulate(int(i) for i in input().split()))
B = list(accumulate(int(i) for i in input().split()))

a,b = [0],[0]
for ai in A:
    a.append(ai)
for bj in B:
    b.append(bj)

cnt = 0
best0 = M
for i in range(N+1):
   ai = a[i]
   for j in range(best0, -1, -1):
       bj = b[j]
       if ai + bj <= K:
           cnt = max(cnt, i + j)
           best0 = j
           break

print(cnt)
### BUGGY CODE ###

N, Y = map(int,input().split())
t = Y//1000
counter = 0
if counter==0:
    for i in range(t//10+1):
        if counter==0:   
            for j in range(t//5+1):
                    if (10000*i+5000*j+1000*(N-i-j))==Y and counter == 0 and N-i-j>=0:
                        counter+=1
                        print(i, j, (N-i-j))
                        break
if counter == 0:
    print(-1, -1, -1)

### FIXED CODE ###

N, Y = map(int,input().split())#調べる要素が少ないものからループしないと実行時間が間に合わない。
counter = 0
if counter==0:
    for i in range(Y//10000+1):
        if counter==0:   
            for j in range((Y-10000*i)//5000+1):
                    if (10000*i+5000*j+1000*(N-i-j))==Y and counter == 0 and N-i-j>=0:
                        counter+=1
                        print(i, j, (N-i-j))
                        break
if counter == 0:
    print(-1, -1, -1)
### BUGGY CODE ###

n=int(input())
l=[int(i) for i in input().split()]
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        ans+=(l[i]*l[j])%1000000007
print(ans%1000000007)

### FIXED CODE ###

n=int(input())
l=[int(i) for i in input().split()]
ans=0
mod=1000000007
sql=(sum(l))**2
for i in l:
    ans+=i*i
print((sql-ans)//2%mod)
### BUGGY CODE ###

def count(item, str1):
    counter = 0
    for c in str1:
        if c == item:
            counter += 1
    return counter

N = int(input())
S = input()
_min = -1
for i in range(N):
    left_str = S[:i]
    right_str = S[i+1:]
    left = count('W', left_str)
    right = count('E', right_str)
    total = left + right
    if _min == -1:
        _min = total
    elif total < _min:
        _min = total
print(_min)
        

### FIXED CODE ###

N = int(input())
S = input()
w_count = 0
e_count = 0
w_counts = [0 for _ in range(N)]
e_counts = [0 for _ in range(N)]
for i in range(N):
    if S[i] == 'W':
        w_count += 1
    w_counts[i] = w_count
for i in range(N-1, -1, -1):
    if S[i] == 'E':
        e_count += 1
    e_counts[i] = e_count
_min = -1
for i in range(N):
    total = w_counts[i] + e_counts[i]
    if _min == -1:
        _min = total
    if _min > total:
        _min = total
print(_min-1)
### BUGGY CODE ###


n=int(input())

a= list(map(int,input().split()))
ans=1
for i in range(n):
    if a[i]==0:
        ans=0
        exit
for i in range(n):
    ans*=a[i]

if ans>10**18:
    ans=-1
print(ans)

### FIXED CODE ###

import numpy as np
n=int(input())
ans=1
a=input().split()
#print(a)
if '0' in a:
    ans=0
    print(ans)
if ans!=0:
    for i in a:
        ans=ans*int(i)
        if ans>10**18:
            ans=-1
            break
    print(ans)
### BUGGY CODE ###

n=int(input())
string_list=[input() for i in range(n)]
s=set(string_list)
t=list(s)
l=[0]*len(t)
a = len(t)
for i in range(n):
  for j in range(a):
    if t[j] == string_list[i]:
      l[j]+=1
u=[]
for k in range(len(t)):
  if l[k] == max(l):
    u.append(t[k])
u.sort()
for x in u:
	print(x)
      
      

### FIXED CODE ###

n = int(input())
s = [input() for _ in range(n)]

import collections
cnt = collections.Counter(s)
dict = sorted(cnt)

max_vote = max(cnt.values())
ans = []
for a,b in cnt.items():
  if max_vote == b:
    ans.append(a)
ans = sorted(ans)
print('\n'.join(ans))
### BUGGY CODE ###

MAX_NUM = 10**6 + 1
MOD = 10**9+7

fac  = [0 for _ in range(MAX_NUM)]
finv = [0 for _ in range(MAX_NUM)]
inv  = [0 for _ in range(MAX_NUM)]

fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

for i in range(2,MAX_NUM):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def cmb(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

mod = 10**9 +7
n, k = map(int, input().split())
a = list(map(int, input().split()))
ascA = sorted(a)

sum_ = 0
for i in range(n-k+1):
    for j in range(i+k-1, n):
        f = ascA[j]-ascA[i]
        c = cmb(j-i-1, k-2)
        #print("%d %d"%(f,c))
        sum_ = (sum_ + (f*c) % mod) % mod

print(sum_)

### FIXED CODE ###

def cmb(n,k, MOD):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

MOD = 10**9+7
n, k = map(int, input().split())
a = list(map(int, input().split()))
ascA = sorted(a)

MAX_N = n
fac  = [0 for _ in range(MAX_N)]
finv = [0 for _ in range(MAX_N)]
inv  = [0 for _ in range(MAX_N)]

fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

for i in range(2,MAX_N):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

sum_ = 0
for i in range(n-k+1):
    f = ascA[n-i-1] - ascA[i]
    c = cmb(n-i-1, k-1, MOD)
    sum_ = (sum_ + (f*c)%MOD) % MOD
    '''
    for j in range(i+k-1, n):
        f = ascA[j]-ascA[i]
        c = cmb(j-i-1, k-2, MOD)
        #print("%d %d"%(f,c))
        sum_ = (sum_ + (f*c) % MOD) % MOD
    '''

print(sum_)
### BUGGY CODE ###

import itertools

N, M, R = map(int, input().split())
r = map(int, input().split())
d = [[float('inf') for j in range(N+1)] for i in range(N+1)]

for i in range(N+1):
    d[i][i] = 0

for i in range(M):
    a, b, c = map(int, input().split())
    t = min(c, d[a][b])
    if d[a][b] > c:
        d[a][b], d[b][a] = t, t

for i in range(N+1):
    for j in range(N+1):
        for k in range(N+1):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = float('inf')
for i in list(itertools.permutations(r)):
    temp = 0
    flag = False
    for j in i:
        if flag:
            temp += d[prev][j]
        else:
            flag = True
        prev = j
    ans = min(ans, temp)

print(ans)

### FIXED CODE ###

from itertools import permutations

def main():
    N, M, R = map(int, input().split())
    r = map(int, input().split())
    inf = float('inf')
    d = [[inf] * N for i in range(N)]

    for i in range(N):
        d[i][i] = 0

    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        if d[a][b] > c:
            d[a][b], d[b][a] = c, c

    for k in range(N):
        for i in range(N):
            for j in range(N):
                temp = d[i][k] + d[k][j]
                if d[i][j] > temp:
                    d[i][j] = temp

    ans = inf
    for i in permutations(r):
        temp = 0
        for j in range(len(i)-1):
            temp += d[i[j] - 1][i[j + 1] - 1]
            if temp > ans:
                break
        if ans > temp:
            ans = temp

    print(ans)


main()
### BUGGY CODE ###

a,b,c,k = map(int, input().split())
cnt = 0
import sys
if a==k:
    cnt = a
    print(cnt)
    sys.exit(0)
for i in range(k):
    if a>0:
        cnt += 1
        a -= 1
    elif b>0:
        cnt += 0
        b -= 1
    elif c>0:
        cnt -= 1
        c -= 1

print(cnt)

### FIXED CODE ###

a,b,c,k = map(int, input().split())
cnt = 0

if a>=k:
    cnt += k
else:
    k -= a
    cnt += a
    if k>0:
        k -= b
        if k>0:
            cnt -= k

print(cnt)
### BUGGY CODE ###

import bisect
import heapq
import math
import queue
import sys
from collections import defaultdict


def main():
    S = input()
    S = S[::-1]
    MOD = 10**9 + 7

    DP_table = defaultdict(int)
    
    digit = S[0]
    if digit == '?':
        for i in range(10):
            DP_table[(1, i)] = 1
    else:
        DP_table[(1, int(digit))] = 1
    
    power_ten = 1
    for i in range(1, len(S)):
        digit = S[i]
        power_ten *= 10
        if digit == '?':
            for j in range(10):
                devided = j * power_ten
                for k in range(13):
                    surplus = (devided + k) % 13
                    DP_table[(i + 1, surplus)] += DP_table[(i, k)] % MOD
                    DP_table[(i + 1, surplus)] %= MOD
        else:
            for k in range(13):
                surplus = (int(digit) * power_ten + k) % 13
                DP_table[(i + 1, surplus)] += DP_table[(i, k)] % MOD
                DP_table[(i + 1, surplus)] %= MOD
                
    print(DP_table[(len(S), 5)])

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    S = {i:s for i, s in enumerate(input()[::-1])}
    MOD = 10**9 + 7

    DP_table = [[0 for i in range(13)] for j in range(len(S))]
    
    digit = S[0]
    if digit == '?':
        for i in range(10):
            DP_table[0][i] = 1
    else:
        DP_table[0][int(digit)] = 1
    
    multiplier = 1
    for i in range(1, len(S)):
        digit = S[i]
        multiplier = multiplier * 10 % 13
        if digit == '?':
            for j in range(10):
                for k in range(13):
                    DP_table[i][(j * multiplier + k) % 13] += DP_table[i-1][k]
        else:
            digit = int(digit)
            for k in range(13):
                DP_table[i][(digit * multiplier + k) % 13] += DP_table[i-1][k]
        
        for j in range(13):
            DP_table[i][j] %= MOD

    print(DP_table[len(S)-1][5])

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

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

import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

Z=((X+Y)/3)

if (X+Y)%3==0 and abs(X-Y)<=Z:
  ans=comb(Z,(X-Z))
  print(ans%(10**9+7))
else:
  print(0)

### FIXED CODE ###

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

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

Z=((X+Y)//3)

if (X+Y)%3==0 and abs(X-Y)<=Z:
  ans=(comb(Z, X-Z,(10**9+7)))
  print(ans)
else:
  print(0)
### BUGGY CODE ###

from sys import stdin
N = int(input())
data = list(input())
bef_ans = 0
for i in range(N-1):#リーダー
  count = 0
  for t in range(N):#向いてるか
    if i < t:
      if data[t] == 'W':
        count += 1
    if i > t:
      if data[t] == 'E':
        count += 1
  if bef_ans < count:
    bef_ans = count
print(N - bef_ans-1)

### FIXED CODE ###

N = int(input())
S = input()
 
eastNumber = S.count('E')
westNumber = 0
minimum = N
 
for i in range(N):
    if S[i] == 'E':
        eastNumber -= 1
        number = eastNumber + westNumber
        if minimum > number:
            minimum = number
    else:
        number = eastNumber + westNumber
        if minimum > number:
            minimum = number
        westNumber += 1
 
print(minimum)
### BUGGY CODE ###

import sys
readline = sys.stdin.readline
read = sys.stdin.read

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

if M == 0:
    print('Yes')
    exit()

*LRD, = map(int, read().split())
graph = [[] for _ in range(N + 1)]

# 根からの距離、根は複数の可能性あり
distance = [-1] * (N + 1)
child = [False] * (N + 1)

for L, R, D in zip(*[iter(LRD)] * 3):
    graph[L].append((R, D))
    child[R] = True

for i in range(1, N + 1):
    if child[i]:
        continue

    # 以下iは根
    distance[i] = 0
    stack = [i]
    while stack:
        V = stack.pop()
        for v, d in graph[V]:
            if distance[v] == -1:
                distance[v] = distance[V] + d
            else:
                if distance[v] != distance[V] + d:
                    print('No')
                    exit()

            stack.append(v)

# 例4のような循環タイプは上のfor内で処理されない
if -1 in distance[1:]:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

import sys
readline = sys.stdin.readline
read = sys.stdin.read

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

if M == 0:
    print('Yes')
    exit()

LRD = map(int, read().split())
graph = [[] for _ in range(N + 1)]

# 根からの距離、根は複数の可能性あり
distance = [-1] * (N + 1)
child = [0] * (N + 1)

for L, R, D in zip(LRD, LRD, LRD):
    graph[L].append((R, D))
    child[R] = 1

for i in range(1, N + 1):
    if child[i]:
        continue

    # 以下iは根
    distance[i] = 0
    stack = [i]
    while stack:
        V = stack.pop()
        for v, d in graph[V]:
            if distance[v] == -1:
                distance[v] = distance[V] + d
                stack.append(v)
            else:
                if distance[v] != distance[V] + d:
                    print('No')
                    exit()

# 例4のような循環タイプは上のfor内で処理されない
if -1 in set(distance[1:]):
    print('No')
else:
    print('Yes')
### BUGGY CODE ###

N = int(input())
M = list(map(int, input().split()))
M = [bin(m)[2:] for m in M]
max_len = max([len(m) for m in M])
M = ["0"*(max_len-len(m))+m for m in M]
MOD = 10**9+7
result = 0
for i in range(1, max_len+1):
  zero = len([m[-i] for m in M if m[-i]=="0"])
  one = len(M) - zero
  #print(one, zero, i)
  result += (((one * zero) % MOD) * ((2 ** (i-1)) % MOD) % MOD)
  result %= MOD
print(result)

### FIXED CODE ###

N = int(input())
M = list(map(int, input().split()))
M = [bin(m)[2:] for m in M]
max_len = max([len(m) for m in M])
M = ["0"*(max_len-len(m))+m for m in M]
MOD = 10**9+7
result = 0
for i in range(1, max_len+1):
  zero = len([m[-i] for m in M if m[-i]=="0"])
  one = len(M) - zero
  #print(one, zero, i)
  result += (((one * zero) % MOD) * ((2 ** (i-1)) % MOD) % MOD)
  result %= MOD
print(result)
### BUGGY CODE ###

n=int(input())
s=[input() for _ in range(n)]
cnt=0
for i in range(n):
  for j in range(n):
    if i>=j:
      continue
    if sorted(s[i])==sorted(s[j]):
      cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
s=[''.join(sorted(input())) for _ in range(n)]
ans=0
cnt={}
for i in range(n):
  if s[i] in cnt:
    cnt[s[i]]+=1
  else:
    cnt[s[i]]=1
print(sum(cnt[key]*(cnt[key]-1)//2 for key in cnt))
### BUGGY CODE ###

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

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


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import Counter


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

    c = Counter(A)

    for i in range(1, N + 1):
        print(c[i])


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

import numpy as np
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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

# kごとに、
# 異なる数がいくつあるかを調べる
# (2以上要素が存在する)異なる数ごとに、
# (要素数)C2を解く。

np_A = np.array(A)

for k in range(N):
    before = A[:k]
    after = A[k+1:]

    before.extend(after)
    tmp_k = np.array(before)
    # print("tmp_k", tmp_k)   # k以上
    # print(np.unique(np_A))

    k_unique = np.unique(tmp_k)
    ans = 0
    for u in k_unique:
        count_u = np.count_nonzero(tmp_k==u)
        if count_u < 2:
            continue

        # (count_u) C 2
        ans += comb(count_u,2)
    
    print(ans)

### FIXED CODE ###

import numpy as np
from collections import Counter


N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
np_A = np.array(A)

# 全体を求める
tmp_all = np.array(A)
unique = np.unique(tmp_all)
# print("unique:", unique)
ans_all = 0
for u in unique:
    count_u = c[u]
    # print(f"u:{u}, count_u:{count_u}")
    if count_u < 2:
        continue
    # (count_u) C 2
    tmp = int(count_u*(count_u-1)/2)
    ans_all += tmp
# print("all", ans_all)


# kごとのケースを求めて、全体から引く
for i in A:
    print(ans_all - c[i] + 1)
### BUGGY CODE ###

n=int(input())
ans=1
for i in range(1,n+1):
	ans*=i

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


### FIXED CODE ###

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

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

N = int(input())
S = input()
ans = 0
for i in range(N-3):
    for j in range(i+1, N-1):
        if S[i] != S[j]:
            for k in range(j+1, N):
                if j-i != k-j and S[i] != S[k] and S[j] != S[k]:
                    ans += 1
print(ans)

### FIXED CODE ###

import copy
N = int(input())
S = input()

R = set()
G = set()
B = set()

for i in range(N):
    if S[i] == "R":
        R.add(i)
    elif S[i] == "G":
        G.add(i)
    else:
        B.add(i)

ans = len(R)*len(G)*len(B)

for r in R:
    for g in G:
        L = g - r
        if g + L in B:
            ans -= 1
        if r - L in B:
            ans -= 1
        if L % 2 == 0 and L//2 + r in B:
            ans -= 1
            



print(ans)