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

n = int(input())
num = input()
 
password_list = []
initial_list = []
initial_list2 = []
initial_list3 = []
 
for i in range(len(num)-2):
    if num[i] in initial_list:
        continue
    elif len(initial_list) == 10:
        break
    else:
        initial_list.append(num[i])
        for j in range(i+1,len(num)-1):
            initial_list2 = []
            if num[j] in initial_list2:
                continue
            elif len(initial_list2) == 10:
                break
            else:
                initial_list2.append(num[j])
                for k in range(j+1,len(num)):
                    initial_list3 = []
                    if num[k] in initial_list3:
                        continue
                    elif len(initial_list3) == 10:
                        break
                    else:
                        initial_list3.append(num[k])
                        target = num[i] + num[j] + num[k]
                        if target not in password_list:
                            password_list.append(target)
print(len(password_list))

### FIXED CODE ###

n = int(input())
num = input()
 
password_list = []
initial_list = []
initial_list2 = []
initial_list3 = []
 
for i in range(len(num)-2):
    initial_list2 = []
    if num[i] in initial_list:
        continue
    elif len(initial_list) == 10:
        break
    else:
        initial_list.append(num[i])
        for j in range(i+1,len(num)-1):
            initial_list3 = []
            if num[j] in initial_list2:
                continue
            elif len(initial_list2) == 10:
                break
            else:
                initial_list2.append(num[j])
                for k in range(j+1,len(num)):
                    if num[k] in initial_list3:
                        continue
                    elif len(initial_list3) == 10:
                        break
                    else:
                        initial_list3.append(num[k])
                        target = num[i] + num[j] + num[k]
                        if target not in password_list:
                            password_list.append(target)
                            
print(len(password_list))
### BUGGY CODE ###

import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    A = np.array(read().split(), dtype=np.int64)

    ans = 0
    for i in range(1,N):
        ans += np.count_nonzero(A[:i] + A[i] == np.arange(i,0,-1))
        
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import Counter
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]

    B = []
    C = []
    for i, a in enumerate(A, start=1):
        B.append(i + a)
        C.append(i - a)

    b = Counter(B)
    c = Counter(C)

    ans = 0
    for k, v in b.items():
        if k in c:
            ans += v * c[k]
    
    print(ans)


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

import sys

sys.setrecursionlimit(10**8)

N, W = map(int, input().split(" "))
WV = [list(map(int, input().split(" "))) for _ in range(N)]

l = [[None for _ in range(W+1)] for _ in range(N+1)]
def dp(i, limit):
    if i == -1:
        return 0
    if l[i][limit] == None:
        w, v = WV[i]
        if w <= limit:
            l[i][limit] = max(
                dp(i-1, limit),
                dp(i-1, limit-w) + v
            )
        else:
            l[i][limit] = dp(i-1, limit)
    return l[i][limit]

print(dp(N-1, W))

### FIXED CODE ###

N, W = map(int, input().split(" "))
WV = [list(map(int, input().split(" "))) for _ in range(N)]

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

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

print(dp[N][W])
### BUGGY CODE ###

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

MOD = 10**9+7

M = 10**3
primes = []
is_prime = [True] * (M+1)
for n in range(2,M+1):
    if not is_prime[n]: continue
    primes.append(n)
    for m in range(2*n,M+1,n): is_prime[m] + False

from collections import defaultdict
D = [defaultdict(int) for _ in range(N)]
cmnd = defaultdict(int)

for i,a in enumerate(A):
    for n in primes:
        while a % n == 0:
            D[i][n] += 1
            a //= n
    if a > 1: D[i][a] += 1
    for k,v in D[i].items():
        cmnd[k] = max(cmnd[k], v)

ans = 0
for i in range(N):
    tmp = 1
    for k,v in cmnd.items():
        tmp *= (k**(v-D[i][k]))%MOD
        tmp %= MOD
    ans += tmp
    ans %= MOD

print(ans)

### FIXED CODE ###

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

MOD=10**9+7
def gcd(a,b):
    while b: a,b=b,a%b
    return a
def lcm(a,b): return a*b//gcd(a,b)

LCM=A[:]
num=N
while num>1:
    for i in range(1,num,2):
        LCM[i//2]=lcm(LCM[i-1],LCM[i])
    if num&1:
        LCM[num//2]=LCM[num-1]
    num=(num+1)//2

ans=0
l=LCM[0]%MOD
for a in A:
    ans+=l*pow(a,MOD-2,MOD)
    ans%=MOD

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

N = int(input())
S = input()
ans = 0
TF = False
for i in range((N//2),-1,-1): #iが長さ
    if TF == True:
        break
    for j in range(N-2*i):    #jは開始位置
        if TF == True:
            break
        tmp = S[j:j+i+1]
        for k in range(j+i+1,N-i):    #kは判断する方の開始位置
            if S[k:k+i+1] == tmp:
                #print("i=",i,"j=",j,"k=",k, tmp)
                ans = i+1
                TF = True
                break
print(ans)

### FIXED CODE ###

#https://atcoder.jp/contests/abc141/submissions/7539109
#Z-Algorithm
n = int(input())
s = input()
 
a = ""
ans = 0
for i in range(n):
    a += s[i]
    while(len(a) > 0):
        if a in s[i+1:]:    #見つかる限りこの処理
            ans = max(ans,len(a))
            break
        else:               #ダメなら次の文字を接頭辞に、短いものは調べなくてよい
            a = a[1:]
print(ans)
### BUGGY CODE ###

import itertools

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

# print(f"{n} {s}")

l = list(s)
# print(l)


set1 = set()
for v1, v2, v3 in itertools.combinations(l, 3):
    # print(f"{v1} {v2} {v3}")
    set1.add(int(v1 + v2 + v3))
    
print(len(set1))

### FIXED CODE ###

import itertools

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

s_l = list(map(int, s))
# print(s_l)

l = [i for i in range(10)]
ans = 0
for v1, v2, v3 in itertools.product(l, repeat=3):
    # print(f"{v1} {v2} {v3}")

    # print(v1) 
    if not v1 in s_l:
        continue
    else:
        index1 = s_l.index(v1)
    
    # print(f"index1 : {index1}")
    # print(s_l[index1 + 1:])
    
    s_l_1 = s_l[index1 + 1:]
        
    if not v2 in s_l_1:
        continue
    else:
        index2 = s_l_1.index(v2)
        
    s_l_2 = s_l_1[index2 + 1:]
        

    if not v3 in s_l_2:
        continue
    

    # print(f"{v1} {v2} {v3}")
    ans += 1
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

S = input()
Symbol = list(S)
MOD =[1,0,0,0,0,0,0,0,0,0,0,0,0]
NMOD =[0,0,0,0,0,0,0,0,0,0,0,0,0]

R10 = range(10)
R13 = range(13)

for D in Symbol:
    C = -1
    if D != '?':
        C = int(D)
    #end if
    for N in R10:
        if C >= 0 and C != N:
            continue
        for M in R13:
            NM = (M * 10 + N) % 13
            NMOD[NM] += MOD[M]
        #end for
    #end for
    for M in R13:
        MOD[M] = NMOD[M]%1000000007
        NMOD[M] = 0
    #end for
#end for

print(MOD[5])


### FIXED CODE ###

# -*- coding: utf-8 -*-

R10 = range(10)
R13 = range(13)

S = input()
R = [[(M-N)*4 % 13 for N in R10] for M in R13]
AM = 10**9+7

MOD =[1]+[0]*12

for D in S:
    if D == '?':
        MOD = [sum([MOD[N] for N in M])%AM for M in R]
    else:
        C = int(D)
        MOD = [MOD[M[C]] for M in R]
    #end if
#end for

print(MOD[5])
### BUGGY CODE ###

import collections
n = int(input())
d = []
s = [input() for _ in range(n)]
ans = 0
for x in s:
    d.append(collections.Counter(list(x)))

for i in range(0, n):
    for j in range(i+1,n):
        if d[i] == d[j]:
            ans += 1
print(ans)

### FIXED CODE ###

from collections import Counter

n = int(input())
w = [""] * n
for i in range(n):
    w[i] = list(input())
    w[i].sort()
    w[i] = "".join(w[i])

w = Counter(w)
ans = 0
for i in w.values():
    ans += i * (i - 1) // 2
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
def main():
    h, w = map(int, input().split())
    s = [input() for _ in range(h)]
    def func(temp, now):
        x, y = now
        if y > h - 1 or x > w - 1:
            return 10**6
        if s[y][x] == "#":
            temp += 1
        if x == w-1 and y == h-1:
            return temp
        return min(func(temp, (x + 1, y)), func(temp, (x, y + 1)))
    print(func(0, (0, 0)))
main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
def main():
    h, w = map(int, input().split())
    s = [input() for _ in range(h)]
    dp = [[10**5] * w for _ in range(h)]
    def func(temp, now, flag):
        x, y = now
        if y > h - 1 or x > w - 1:
            return 10**6
        if s[y][x] == "#":
            if not flag:
                temp += 1
            flag = True
        else:
            flag = False
        if x == w-1 and y == h-1:
            return temp
        if dp[y][x] <= temp:
            return 10**6
        dp[y][x] = temp
        piyo = []
        return min(func(temp, (x + 1, y), flag), func(temp, (x, y + 1), flag))
    print(func(0, (0, 0), False))
main()
### BUGGY CODE ###

n = int(input())
A = [int(i) for i in input().split()]
product = 1

for i in range(n):
  product *= A[i]

if(product - 10**18 > 0):
    print("-1")
else:
  print(product)

### FIXED CODE ###

n = int(input())
A = [int(i) for i in input().split()]
product = 1
A.sort()

for i in range(n):
  product *= A[i]
  if(product > 10**18):
    print("-1")
    break

if(product <= 10**18):
  print(product)
### BUGGY CODE ###

def main():

    R, C, K = map(int, input().split())
    a = dict()
    for _ in range(K):
        r, c, v = map(int, input().split())
        a[(r-1, c-1)] = v

    dp = [[[0]*4 for _ in range(C+1)] for _ in range(R+1)]

    for i in range(R):
        for j in range(C):
            v = max(dp[i][j+1])
            for k in range(4):
                dp[i+1][j+1][k] = dp[i+1][j][k]
            dp[i+1][j+1][0] = max(dp[i+1][j+1][0], v)
            if (i, j) in a:
                dp[i+1][j+1][1] = max([dp[i+1][j+1][1],  dp[i+1][j][0] + a[(i, j)],  v + a[(i, j)]])
                dp[i+1][j+1][2] = max([dp[i+1][j+1][2], dp[i+1][j][1] + a[(i, j)] ])
                dp[i+1][j+1][3] = max([dp[i+1][j+1][3], dp[i+1][j][2] + a[(i, j)] ])

    return max(dp[R][C])


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

def main():

    R, C, K = map(int, input().split())
    a = dict()
    for _ in range(K):
        r, c, v = map(int, input().split())
        a[(r-1, c-1)] = v

    dp = [[[0]*4 for _ in range(C+1)] for _ in range(2)]

    for i in range(R):
        for j in range(C):
            v = max(dp[0][j+1])
            u = 0
            if (i, j) in a: u = a[(i, j)]
            dp[1][j+1][0] = max(dp[1][j+1][0], v)
            dp[1][j+1][1] = max(dp[1][j+1][1], dp[1][j][1], dp[1][j][0] + u,  v + u)
            dp[1][j+1][2] = max(dp[1][j+1][2], dp[1][j][2], dp[1][j][1] + u )
            dp[1][j+1][3] = max(dp[1][j+1][3], dp[1][j][3], dp[1][j][2] + u )
        dp[1], dp[0] = dp[0], dp[1]

    return max(dp[0][C])

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

s = input()
length = len(s)
count_dict = {}

num = int(s)%2019
count_dict[num] = 1

for i in range(1,length):
    num = (num-int(s[-i])*10**(i-1))%2019
    if num not in count_dict:
        count_dict[num] = 1
    else:
        count_dict[num] += 1

count = 0
for k,v in count_dict.items():
    count += v*(v-1)/2
    if k == 0:
        count += v

print(int(count))

### FIXED CODE ###

s = input()
length = len(s)
count_dict = {}

'''for i in range(length-4):
    for j in range(i+4,length+1):
        num = int(s[i:j])
        if num%2019 == 0:
            count += 1'''

num = int(s)%2019
count_dict[num] = 1

# num = int(s[-1])
# count_dict[num] = 1

for i in range(1,length):
    num = (num-int(s[-i])*pow(10,(i-1),2019))%2019
    # num = num+int(s[-i])
    if num not in count_dict:
        count_dict[num] = 1
    else:
        count_dict[num] += 1


count = 0
for k,v in count_dict.items():
    count += v*(v-1)/2
    if k == 0:
        count += v

print(int(count))
### BUGGY CODE ###

from math import ceil
from copy import deepcopy

N0 = int(input())
ans = 0


for K in range(2, N0+1):
    N = deepcopy(N0)
    #print("K", K)
    # 下処理、N -> N/K を可能な限り行う。いずれ割り切れなくなる
    while (N % K == 0):
        #print("step1", N, "to", N//K)
        N = N // K

    # 割り切れない場合 N -> N-K を可能な限り行う
    #print("step2", N, "to", N - K * (ceil(N/K) - 1))
    N = N - K * (ceil(N/K) - 1)

    # 判定
    #print("judge", N, N==1, "\n")
    if N == 1:
        ans += 1

print(ans)


### FIXED CODE ###

from copy import deepcopy

# 約数を全列挙する関数
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    divisors.sort()
    return divisors

N0 = int(input())
ans = 0

# N = K^a (bK + 1) と表現できるので K は N or N-1 の約数であることが必要
K_cand = set(make_divisors(N0) + make_divisors(N0-1))

for K in K_cand:
    N = deepcopy(N0)
    if K == 1:  # K = 1 を除外
        continue
    else:
        while N%K == 0:
            N = N // K  # 割れるだけ割る
        N = N%K  # 引けるだけ引く
        if N == 1:
            ans += 1

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

N,Y = map(int, input().split())
tmp = 0
sum = 0
end_flg = 0


for x in range(N+1):
    if end_flg == 1:break
    for y in range(N+1):
        if end_flg == 1:break
        for z in range(N+1):
            tmp = 10000*x + 5000*y + 1000*z
            sum = x+y+z
            if tmp == Y and sum == N:
                print(x,y,z)
                end_flg = 1
                break;

if(end_flg!=1):print("-1 -1 -1")



### FIXED CODE ###

import sys
n,y = map(int,input().split())
for i in range(0,n+1):
    for j in range(0,n-i+1):
        if i*10000 + j*5000 + (n-i-j)*1000 == y:
            print('{0} {1} {2}'.format(i,j,n-i-j))
            sys.exit()
 
print('{0} {1} {2}'.format(-1,-1,-1))
### BUGGY CODE ###

from itertools import *
from collections import defaultdict
def ints():
  return [int(x) for x in input().split()]
def readi():
  return int(input())

N, K = ints()
A = ints()
S = [0] + list(accumulate(A))

def f(i):
  return (S[i]-i)%K

s = 0
for j in range(1, N+1):
  fj = f(j)
  for i in range(max(0, j-K+1), j):
    if f(i)==fj:
      s += 1
print(s)


### FIXED CODE ###

from itertools import *
from collections import defaultdict
def ints():
  return [int(x) for x in input().split()]
def readi():
  return int(input())

N, K = ints()
A = ints()
S = [0] + list(accumulate(A))

def f(i):
  return (S[i]-i)%K

s = 0
memo = defaultdict(int)
for j in range(1, N+1):
  fj = f(j)

  if j-K>=0:
    memo[f(j-K)] -= 1
  memo[f(j-1)] += 1

  s += memo[fj]
print(s)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
num = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
ans = {0: 0, 1: 0}
for i in range(2, N + 1):
    x = 0
    for j in A:
        k = num[j]
        if i - k < 0:
            continue
        if i == k:
            x = max(x, j)
            continue
        if i - k in ans:
            an = ans[i - k]
            if an == 0:
                continue
            x = max(x, an * 10 + j)
            x = max(x, j * 10 ** len(str(an)) + an)
    ans[i] = x
print(ans[N])

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
num = [2, 5, 5, 4, 5, 6, 3, 7, 6]
ans = {}
for i in range(N + 1):
    x = 0
    for j in A:
        k = num[j - 1]
        if i - k < 0:
            continue
        if i == k:
            x = max(x, j)
            continue
        an = ans[i - k]
        if an == 0:
            continue
        x = max(x, an * 10 + j)
    ans[i] = x
print(ans[N])
### BUGGY CODE ###

from sys import stdin
from sys import  setrecursionlimit
setrecursionlimit(60000)

[H, N] = [int(x) for x in stdin.readline().rstrip().split()]
As = []
Bs=[]
for i in range(N):
    [A, B] = [int(x) for x in stdin.readline().rstrip().split()]
    As.append(A)
    Bs.append(B)

dp_map = []
for i in range(N+1):
    temp_arr = [-1 for _ in range(H+1)]
    dp_map.append(temp_arr)
#dp_map = [[-1]*(H+1)]*(N+1)
#print(len(dp_map))
#print(len(dp_map[0]))

def DP(i, j):
    if j<=0:
        return 0
    if dp_map[i][j]!=-1:
        return dp_map[i][j]
    
    if i==1:
        dp_map[i][j] = DP(i,j-As[i-1])+Bs[i-1]
        return dp_map[i][j]

    dp_map[i][j] = min(DP(i-1,j),DP(i,j-As[i-1])+Bs[i-1])
    return dp_map[i][j]

print(DP(N,H))

### FIXED CODE ###

from sys import stdin
from sys import  setrecursionlimit
setrecursionlimit(10000)

[H, N] = [int(x) for x in stdin.readline().rstrip().split()]
As = []
Bs=[]
for i in range(N):
    [A, B] = [int(x) for x in stdin.readline().rstrip().split()]
    As.append(A)
    Bs.append(B)

INF = 10**10
dp_map = [[INF]*(H+1) for _ in range(N+1)]

#dp_map[i][j]: i番目の魔法までを使って、最低でもjのダメージを与える時に必要なMP
dp_map[0][0]  = 0
for i in range(N):
    for j in range(H+1):
        if j<As[i]:
            dp_map[i+1][j] = min(dp_map[i+1][0]+Bs[i],dp_map[i][j])
        else:
            dp_map[i+1][j] = min(dp_map[i+1][j-As[i]]+Bs[i] ,dp_map[i][j])

print(dp_map[N][H])
### BUGGY CODE ###

def get_values():
    return [int(a) for a in input().split()]

N, = get_values()
Xs = get_values()

for idx, xi in enumerate(Xs):
    Ys = sorted(Xs[:idx] + Xs[idx+1:])
    print(Ys[len(Ys) // 2])

### FIXED CODE ###

def get_values():
    return [int(a) for a in input().split()]

# PROBLEM C
N, = get_values()
Xs = get_values()

Ys = sorted(Xs)
mdx = len(Ys) // 2
x2b = {x:Ys[mdx if idx < mdx else mdx - 1] for idx, x in enumerate(Ys)}
for x in Xs:
    print(x2b[x])
### BUGGY CODE ###

import collections
import math
n = int(input())
aa = list(map(int, input().split()))

def factor(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
memo = {}
a = collections.Counter(aa)
ans = 0
for i in range(len(aa)):
    if not aa[i] in memo:
        aaa = a[aa[i]]
        if aaa - 2 >= 0:
            sub = factor(aaa, 2)
            memo[aa[i]] = sub
        else:
            memo[aa[i]] = 0

memo2 = {}
for i in range(len(aa)):
    if not aa[i] in memo2:
        aaa = a[aa[i]] - 1
        if aaa - 2 >= 0:
            sub = factor(aaa, 2)
            memo2[aa[i]] = sub
        else:
            memo2[aa[i]] = 0

for i in range(len(aa)):
    ans = 0
    ans += memo2[aa[i]]
    for key in memo:
        if aa[i] != key:
            ans += memo[key]
    print(ans)

### FIXED CODE ###

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

sub = collections.Counter(a)
ans = 0
for i in sub:
    ans += sub[i] * (sub[i] - 1) // 2
for i in range(n):
    ad = sub[a[i]] * (sub[a[i]] - 1) // 2 - ((sub[a[i]] - 1) * (sub[a[i]] - 2) // 2)
    print(ans - ad)
### BUGGY CODE ###

n,k=map(int,input().split())
hps=list(map(int,input().split()))
hps.sort()
if k>n:
  print(0)
elif k==n:
  print(0)
else:
  ans=0
  for i in range(k):
    hps=hps[0:-1]
  ans+=sum(hps)
  print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
hps=list(map(int,input().split()))
hps.sort()
if k>n:
  print(0)
elif k==n:
  print(0)
else:
  ans=0
  for i in range(k):
    hps.pop()
  ans+=sum(hps)
  print(ans)
### BUGGY CODE ###

import itertools

k, s = (int(x) for x in input().split())
sum_ = 0
for x, y, z in itertools.product(range(k+1), range(k+1), range(k+1)):
    if x + y + z == s:
        sum_ += 1
print(sum_)


### FIXED CODE ###

k, s = (int(x) for x in input().split())
sum_ = 0
for x in range(k+1):
  for y in range(k+1):
    if 0 <= s-x-y <= k:
        sum_ += 1
print(sum_)
### BUGGY CODE ###

#
from collections import deque

import sys

def main():
    n, m = map(int, input().split())

    edges = [[] for _ in range(n + 1)]

    for _ in range(m):
        u, v = map(int, sys.stdin.readline().split())
        edges[u].append(v)
    # print(edges)

    s, t = map(int, input().split())

    def next_kenp(node, edges, dones):
        nodes = set()
        nodes2 = set()

        for n1 in edges[node]:
            for n2 in edges[n1]:
                if n2 not in nodes2:
                    nodes2.add(n2)

        for nn in nodes2:
            for n3 in edges[nn]:
                if n3 in dones or n3 in nodes:
                    continue
                nodes.add(n3)
        return nodes

    dones = set()
    que = deque()
    que.append((s, 0))
    while que:
        node, step = que.popleft()
        next_nodes = next_kenp(node, edges, dones)
        for n in next_nodes:
            if n == t:
                print(step + 1)
                exit()

            que.append((n, step + 1))
            dones.add(n)

    print(-1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n, m = map(int, input().split())

    edges = defaultdict(list)

    for _ in range(m):
        u, v = map(int, input().split())
        edges[(u, 0)].append((v, 1))
        edges[(u, 1)].append((v, 2))
        edges[(u, 2)].append((v, 0))

    s, t = map(int, input().split())

    # print(new_edges)

    dones = set()
    que = deque()
    que.append(((s, 0), 0))
    while que:
        node, step = que.popleft()

        next_nodes = edges[node]
        # print(next_nodes)
        for n, l in next_nodes:
            if n == t and l == 0:
                print((step + 1) // 3)
                exit()

            if (n, l) not in dones:
                que.append(((n, l), step + 1))
                dones.add((n, l))
    print(-1)


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

# a < b + c
# b < a + C
# c < a + b

# 4 3 2 1
# a b c 

# abs(a - b) < c < a + b
# a < b < c
# b - a < b < c
# c < a + b 

from math import ceil, floor
from bisect import bisect_left, bisect_right

def solution(N, data): # O(N^2 * logN)
    data = sorted(data)
    c = 0
    for i in range(N):
        for j in range(i+1, N-1):
            max_t = data[i] + data[j]
            max_i = bisect_right(data[j+1:], max_t-1)

            c += max_i

    return c

if __name__ == '__main__':
    N = int(input())
    L_i = list(map(int, input().split()))
    a = solution(N, L_i)
    print(a)



### FIXED CODE ###

# a < b + c
# b < a + C
# c < a + b

# 4 3 2 1
# a b c 

# abs(a - b) < c < a + b
# a < b < c
# b - a < b < c
# c < a + b 

from math import ceil, floor
from bisect import bisect_left, bisect_right

def solution(N, data): # O(N^2 * logN)
    data.sort()
    c = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            c += bisect_left(data, data[i] + data[j], j) - j - 1

    return c

if __name__ == '__main__':
    N = int(input())
    L_i = list(map(int, input().split()))
    a = solution(N, L_i)
    print(a)
### BUGGY CODE ###

N = int(input())
S = input()
ans = N
E = [0] * N
W = [0] * N
for i in range(N):
    if S[i] == 'E': E[i] = 1
    else: W[i] = 1
for i in range(N):
    LR = sum(W[:i]) + sum(E[i+1:])
    if LR < ans: ans = LR
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = N
E = [0] * (N + 1)
for i in range(N):
    E[i+1] = E[i] + (S[i] == 'E')
for i in range(N):
    LR = i - E[i] + E[N] - E[i+1]
    if LR < ans: ans = LR
print(ans)