Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 14 10:14:13 2018
ALDS1_11_D
@author: maezawa
"""

n, m = list(map(int, input().split()))
v = [-1 for _ in range(n)]
stack = []
adj = [[] for _ in range(n)]
for i in range(m):
    s, t = list(map(int, input().split()))
    adj[s].append(t)
    adj[t].append(s)
#print(*adj, sep='\n')
def dfs(u, color):
    if v[u] > 0:
        return 0
    v[u] = color
    #print(u, current, stack)
    for k in adj[u]:
        if v[k] > 0:
            continue
        dfs(k, color)
    return 1

color = 1
for start in range(n):
    if dfs(start, color) == 1:
        color += 1
#for i in range(n):        
#    print('color:{} for node:{}'.format(i, v[i]))

q = int(input())
for i in range(q):
    s, t = list(map(int, input().split()))
    if v[s] == v[t]:
        print('yes')
    else:
        print('no')


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Jul 14 10:14:13 2018
ALDS1_11_D
@author: maezawa
"""
import sys
sys.setrecursionlimit(1000000)

n, m = list(map(int, input().split()))
v = [-1 for _ in range(n)]
stack = []
adj = [[] for _ in range(n)]
for i in range(m):
    s, t = list(map(int, input().split()))
    adj[s].append(t)
    adj[t].append(s)
#print(*adj, sep='\n')
def dfs(u, color):
    if v[u] > 0:
        return 0
    v[u] = color
    #print(u, current, stack)
    for k in adj[u]:
        if v[k] > 0:
            continue
        dfs(k, color)
    return 1

color = 1
for start in range(n):
    if dfs(start, color) == 1:
        color += 1
#for i in range(n):        
#    print('color:{} for node:{}'.format(i, v[i]))

q = int(input())
for i in range(q):
    s, t = list(map(int, input().split()))
    if v[s] == v[t]:
        print('yes')
    else:
        print('no')
import bisect
ans = 0
N = int(input())
a = list(map(int,input().split()))
b = [True for _ in range(N)]
a.sort()
digit = 40
y = 2 ** (digit+1) -1
while len(a)>1:
    if b[-1]==False:
        a.pop(-1)
        b.pop(-1)
        continue
    x = a.pop(-1)
    b.pop(-1)
    while x < 2**digit:
        digit -= 1
        y = 2 ** (digit+1) -1
    z = x^y
    z += 1
    ll =  bisect.bisect_left(a,z)
    rr =  bisect.bisect_right(a,z)
    if rr-ll>0:
        rr -= 1
        while b[rr] == False:
            rr -= 1
        if rr>=ll:
            b[rr] = False
            ans += 1           
print(ans)

### FIXED CODE ###

import bisect
ans = 0
N = int(input())
a = list(map(int,input().split()))
b = [True for _ in range(N)]
c = [True for _ in range(N)]
a.sort()
digit = 40
y = 2 ** (digit+1) -1
while len(a)>1:
    if b[-1]==False:
        a.pop(-1)
        b.pop(-1)
        continue
    x = a.pop(-1)
    b.pop(-1)
    while x < 2**digit:
        digit -= 1
        y = 2 ** (digit+1) -1
    z = x^y
    z += 1
    ll =  bisect.bisect_left(a,z)
    rr =  bisect.bisect_right(a,z)
    if rr-ll>0:
        rr -= 1
        if b[ll]==False:
            pass
        elif b[rr]==True:
            b[rr]=False
            ans += 1
        else:
            lll = ll
            rrr = rr
            while rrr-lll>1:
                if b[(rrr+lll)//2]:
                    lll = (rrr+lll)//2
                else:
                    rrr = (rrr+lll)//2
            b[lll] = False
            ans += 1           
print(ans)
from collections import Counter, defaultdict, deque

class UnionFind(object):
    """Union find tree."""
    def __init__(self):
        self.par = {}
        self.sizes = {}

    def root(self, key):
        if key not in self.par:
            if key not in self.sizes:
                self.sizes[key] = 1
            return key
        self.par[key] = self.root(self.par[key])
        return self.par[key]

    def is_same(self, a, b):
        return self.root(a) == self.root(b)

    # return `now` connected nodes
    def merge(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra != rb:
            sa = self.sizes[ra]
            sb = self.sizes[rb]
            self.par[ra] = rb
            self.sizes[rb] += sa
            return sa * sb
        return 0

N, M = map(int, input().split())
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))

uni = UnionFind()
comb = N * (N - 1) // 2
anses = [comb]
for a, b in AB[-1:0:-1]:
    red = uni.merge(a, b)
    comb -= red
    anses.append(comb)

for ans in reversed(anses):
    print(ans)

### FIXED CODE ###

from collections import Counter, defaultdict, deque

class UnionFind(object):
    """Union find tree."""
    def __init__(self, nodes):
        self.par = list(range(nodes + 1))
        self.sizes = [1] * (nodes + 1)

    def root(self, key):
        if key != self.par[key]:
            k0 = key
            while k0 != self.par[k0]:
                k0 = self.par[k0]
            self.par[key] = k0
        return self.par[key]

    def merge(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra != rb:
            sa = self.sizes[ra]
            sb = self.sizes[rb]
            self.par[ra] = rb
            self.sizes[rb] += sa
            return sa * sb
        return 0

N, M = map(int, input().split())
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))

uni = UnionFind(N)
comb = N * (N - 1) // 2
anses = [comb]
for a, b in AB[-1:0:-1]:
    red = uni.merge(a, b)
    comb -= red
    anses.append(comb)

for ans in reversed(anses):
    print(ans)
n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = 10**9
  
for i in range(n-k+1):
  if x[k-1+i]*x[i] < 0:
    if x[k-1+i] <= abs(x[i]) :
      temp = 2*x[k-1+i] - x[i]
    elif abs(x[i]) < x[k-1+i]:
      temp = x[k-1+i] - 2*x[i]
      
  elif (0 <= x[i]):
    temp = x[k+i-1]

  elif (x[k+i-1] <= 0) and ():
    temp = -x[0]
    
  if temp < ans:
    ans = temp
    
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = 10**9
  
for i in range(n-k+1):
  if x[k-1+i]*x[i] < 0:
    if x[k-1+i] <= abs(x[i]) :
      temp = 2*x[k-1+i] - x[i]
    elif abs(x[i]) < x[k-1+i]:
      temp = x[k-1+i] - 2*x[i]
      
  elif (0 <= x[i]):
    temp = x[k+i-1]

  elif (x[k+i-1] <= 0):
    temp = -x[i]
    
  if temp < ans:
    ans = temp
    
print(ans)
#ABC164C
def main():
    import sys
    N, limit = map(int, sys.stdin.readline().split())
    L = tuple([tuple(map(int, sys.stdin.readline().split())) for _ in range(N)])
    dp = [[0 for _ in range(limit+1)] for _ in range(N)]
    dp[0][L[0][0]] = L[0][1] #初期値
    for i in range(1, N):
        dp[i] = dp[i-1].copy() #前回をコピー(初)
        w, v = L[i][0], L[i][1]
        dp[i][w] = max(v, dp[i][w])
        for j in range(limit+1-w):
            if dp[i-1][j] >0:
                dp[i][w+j] = max(v+ dp[i-1][j], dp[i][w+j])
            
    
    
    print(max(dp[-1]))



if __name__=='__main__':
    main()


### FIXED CODE ###

import sys
n, W = map(int, sys.stdin.readline().split())
L = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]

dp = [[0 for _ in range(W+1)] for _ in range(n)]
for w in range(W+1):
    if w>=L[0][0]:
        dp[0][w] = L[0][1]

#print(dp)
for i in range(1, n):
    for w in range(W+1):
        if w <L[i][0]: #そもそも加えられないとき
            dp[i][w] = dp[i-1][w] #前回の状態を代入。
        else: #加えようとしたら入るとき
            dp[i][w] = max(dp[i-1][w-L[i][0]] + L[i][1], dp[i-1][w]) #max(加えた時の価値, 前回の状態)
            
#print(dp)
print(max(dp[-1]))
n, m = map(int, input().split())
a = list(map(int, input().split()))

ans = 0

l = [0]*(n+1)

for i in range(n):
    l[i+1] = (a[i]+l[i])%m

b = [0]*m

for i in range(n+1):
    b[l[i]]+=1

for i in range(m):
    if b[i] >1:
        ans += sum(range(1,b[i]))

print(ans)

### FIXED CODE ###

from itertools import accumulate
from collections import Counter
import math


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

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

a = [0]+a
b = list(accumulate(a))

for i in range(len(b)):
    b[i]%=m


c = Counter(b)

ans = 0

for x in c:
    if c[x]>1:
        ans += combinations_count(c[x],2)

print(ans)
n = int(input())
d = list(map(int,input().split()))
d.sort()
if d[0] != 0 or d[1] == 0:
    ans = 0
else:
    cnt = [0]*n
    for i in range(1, n):
        cnt[d[i]] += 1

ans = 1
for i in range(2, n):
    ans *= cnt[i-1]**cnt[i]
print(ans)

### FIXED CODE ###

from collections import Counter


def solve(n, ddd):
    if ddd[0] != 0:
        return 0
    cnt = Counter(ddd)
    if cnt[0] != 1:
        return 0
    max_c = max(cnt)
    for i in range(max_c + 1):
        if i not in cnt:
            return 0

    MOD = 998244353
    ans = 1
    for i in range(max_c):
        prev = cnt[i]
        curr = cnt[i + 1]
        ans = ans * pow(prev, curr, MOD) % MOD
    return ans


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

print(solve(n, ddd))
(a, b, c) = (int(i) for i in input().sprit())

count = 0

for i in range(a, b + 1) :
    if c % i == 0 :
        count += 1


print(count)

### FIXED CODE ###

(a, b, c) = (int(i) for i in input().split())

count = 0

for i in range(a, b + 1) :
    if c % i == 0 :
        count += 1

print(count)
N,W = map(int,input().split())
info = [list(map(int,input().split())) for i in range(N)]
# dp[i+1][w] i+1番目まで品物を選んで重さwのときの価値の最大値
# dp[0] = [0]*(W+1)
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(N):
    for w in range(W+1):
        if  w - info[i][0] >= 0:
            dp[i+1][w] = max(dp[i][w-info[i][0]] + info[i][1],dp[i][w])
        else:    
            dp[i+1][w] = dp[i][w]
print(dp[N][W])

### FIXED CODE ###

N,W = map(int,input().split())
value,weight = [],[]
def chmin(a,b):
    if (a > b):
        a = b
        return True
    return False
for i in range(N):
    w,v = map(int,input().split())
    value.append(v)
    weight.append(w)
# dp[i][v]: i番目までの品物から価値vを超えるように選んだ時の重さの最小値
dp = [[float("inf")] * (sum(value)+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    for v in range(sum(value)+1):
        if v - value[i-1] >= 0:
            dp[i][v] = min(dp[i-1][v-value[i-1]] + weight[i-1],dp[i-1][v])
        else:
            dp[i][v] = dp[i-1][v]
ans = 0
for v in range(sum(value),-1,-1):
    if dp[N][v] <= W:
        ans = v
        break
print(ans)
s = int(input())
A = list(map(int, input().split())) 
m = max(A)
if sum(A) - int(m) > int(m):
    print("Yes")
else:
    print("NO")

### FIXED CODE ###

s = input().split()
print(int(s[0])/int(s[1]))
a, b, x = map(int, input().split())
print( ( -(a - a%x) + (b - b%x) )  // x + 1 if a != b else (1 if a%b==0 else 0))

### FIXED CODE ###

a, b, x = map(int, input().split())
print(b//x - (-(-a//x)) + 1)
s = list(input())
w =[]
for i in s:
    if i == "B":
        w.pop(-1)
    else:
        w.append(i)
print("".join(w))


### FIXED CODE ###

s = list(input())
w =[]
for i in s:
    if i == "B":
        if len(w) !=0:
            w.pop(-1)
    else:
        w.append(i)
print("".join(w))
a,b = map(int,input().split())
N = list(map(int,input().split()))
N.sort()
for i in range(b):
    if N:
        N.pop()
print(sum(N))

### FIXED CODE ###

h = int(input())

result = 0
i = 1
while h > 0:
    h = h // 2
    result = result + i
    i *= 2

print(result)
c, r = map(int, input().split())
last_list = [0] * r
for _ in range(c):
    n = 0
    x = input()
    sum_list = list(map(int, x.split()))
    for i in range(r):
        last_list[i] += sum_list[i]
        n += sum_list[i]
    print(x+" "+str(n))

sum = 0   
for a in last_list:
    sum += a
print(*last_list, sum)

### FIXED CODE ###

r, c = map(int, input().split())
last_list = [0] * (c + 1)
for _ in range(r):
    n = 0
    x = input()
    sum_list = list(map(int, x.split()))
    for i in range(c):
        last_list[i] += sum_list[i]
        n += sum_list[i]
    print(x, n)

last_list[-1] = sum(last_list)
print(*last_list)
while True:
 n, x = map(int(input().split()))
 if n == x == 0:
  break
 count = 0
 for a in range(1, n):
  for b in range(a + 1, n):
   for c in range(b + 1, n):
    Sum = a + b + c
    if Sum == x:
     count += 1
 print(count)

### FIXED CODE ###

while True:
 n, x = map(int, input().split())
 if n == x == 0:
  break
 Sum = 0
 count = 0
 for a in range(1, n + 1):
  for b in range(a + 1, n + 1):
   for c in range(b + 1, n + 1):
    Sum = a + b + c
    if Sum == x:
     count = count + 1
 print(count)
n,m = map(int,input().split())
digit = [0]*m
num = [0]*m
for i in range(m):
    digit[i], num[i] = map(int, input().split())
for i in range(1000):
    dum = str(i)
    flag = "ok"
    for j in range(m):
        #print(j)
        if len(dum) == (n+1-digit[j]):
            if dum[digit[j]-1] != str(num[j]):
                flag = "ng"
                break
        else:
            flag = "ng"
            break
    if flag == "ok":
        print(dum)
        break
else:
    print(-1)

### FIXED CODE ###

check = 0
check2 = 0
kensa = 0
kekka = "" 
num = []
hantei = "OK"
INF = input().split()
gyosu = int(INF[1])
keta = int(INF[0])
out = []
for l in range(keta):
  out.append(0)


for i in range(gyosu):
  num.append([int(j) for j in input().split()])

if gyosu > 0 :
  check = int(num[0][0])
  check2 = int(num[0][1])
  
  for j in range(gyosu-1):
    for k in range(gyosu-1):
      if num[j][0] == num[k + 1][0]:
        if num[j][1] != num[k + 1][1]:
          hantei = "NG"
    
    if int(num[j][0]) < check: # 入力値にある最大桁数を計算
      check = int(num[j][0])
      check2 = int(num[j][1])
  if check2 == 0:
    if check == 1 and keta == 3:
      hantei = "NG"
    if check == 2:
      hantei = "tokubetu2"
    if check == 3:
      hantei = "tokubetu"

if hantei == "NG":
  print("-1")
else:
  for m in range(gyosu):
    
    out[(num[m][0] - 1)] = num[m][1]
  for n in range(keta):
    kekka = kekka + str(out[n])

  for p  in kekka:
      if p == "0":
        kensa = kensa + 1
      else:
        break
  kekka2 = kekka
  for q in range(kensa):
    if keta != 1:
      kekka = kekka.lstrip("0")
if hantei == "OK":
  if gyosu == 0:
    if keta == 1:
      print("0")
    elif keta == 2:
      print("10")
    else:
      print("100")
  else:
    if keta == 2:
      if kensa == 1:
        kekka = "1" + kekka
    if keta == 3:
      if kensa == 1:
        kekka = "1" + kekka
      if kensa == 2:
        kekka = "10" + kekka
    print(kekka)

if hantei == "tokubetu":
  print("0")


if hantei == "tokubetu2":
  #kekka2 = kekka2.lstrip("0")
  kekka2 = kekka2[1:]
  kekka2 = "1" + kekka2
  print(kekka2)
N=input()
stu=list(map(int,input().split()))
stu2=list(range(8))
for i in range(N):
  for j in range(N):
    if stu[i]==j:
      stu2[j-1]=i+1
print(stu2)


### FIXED CODE ###

N=int(input())
stu=list(map(int,input().split()))
stu2=list(range(N))
for i in range(N):
    stu2[stu[i]-1]=i+1
print(*stu2,end=' ')
N, M = map(int, input().split())
MOD = 10**9+7

def factorize(N):
    res = {}
    for i in range(2, N):
        if i**2 > N: break
        if N % i != 0: continue
        num = 0
        while N % i == 0:
            N = int(N/i)
            num += 1
        res[i] = num
    if N>1: res[N] = 1
    return res

res = factorize(M)

n = max(res.values()) + N + 1

fac = [1]*n
inv = [1]*n
finv = [1]*n

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

ans = 1
for m in res.values():
    a = fac[m+N-1] * (finv[m] * finv[N-1] % MOD) % MOD
    ans = ans*a%MOD

print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
MOD = 10**9+7

def factorize(N):
    res = []
    for i in range(2, N):
        if i**2 > N: break
        if N % i != 0: continue
        num = 0
        while N % i == 0:
            N = int(N/i)
            num += 1
        res.append(num)
    if N>1: res.append(1)
    return res

res = factorize(M) if M>1 else [0]

n = max(res) + N 

fac = [1]*n
inv = [1]*n
finv = [1]*n

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

ans = 1
for m in res:
    a = fac[m+N-1] * (finv[m] * finv[N-1] % MOD) % MOD
    ans = ans*a%MOD

print(ans)
S = input()

ans = 'NO'
def func(T):
    global ans
    if len(T) > len(S):
        return
    if S == T:
        ans = 'YES'
        return

    if S[len(T)] == 'd':
        func(T+'dream')
        func(T+'dreamer')
    if S[len(T)] == 'e':
        func(T+'erase')
        func(T+'eraser')

func('')

print(ans)



### FIXED CODE ###

S = input()

ans = 'YES'

while S:
    if S.endswith('eraser'):
        S = S[:-6]
    elif S.endswith('erase'):
        S = S[:-5]
    elif S.endswith('dreamer'):
        S = S[:-7]
    elif S.endswith('dream'):
        S = S[:-5]
    else:
        ans = 'NO'
        break

print(ans)
import sys
from pprint import pprint

def solve(n, k, p):
    E = [(1.0 + p_i)/2 for p_i in p]
    # pprint(E)
    
    ans = 0
    for i in range(n - k + 1):
        # print(i+3)
        ans = max(ans, sum([E[i+j] for j in range(k)]))
        # print(i, sum([E[i+j] for j in range(k)]))
    print(ans)

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    p = list(map(int, sys.stdin.readline().strip().split(" ")))
    solve(n, k, p)

### FIXED CODE ###

import sys
from pprint import pprint

def solve(n, a):
    exists = set()
    for a_i in a:
        if a_i in exists:
            return "NO"
        exists.add(a_i)
    return "YES"

if __name__ == '__main__':
    n = sys.stdin.readline().strip()
    a = list(map(int,sys.stdin.readline().strip().split(" ")))
    
    print(solve(n, a))
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def calc_rle(s):
    tmp, count, ans = s[0], 1, ""
    for i in range(1, len(s)):
        if tmp == s[i]:
            count += 1
        else:
            ans += tmp + str(count)
            tmp = s[i]
            count = 1
    ans += tmp + str(count)
    return ans


s = S()
rle = calc_rle(s)
if 'W' not in s or 'B' not in s:
    print(0)
    sys.exit()
# print(rle)
if rle[0] == 'W':
    rle = rle[2:]
if len(rle) // 2 >= 2 and rle[-2] == 'B':
    rle = rle[:-2]
# print(rle)
rle = [[rle[i], eval(rle[i+1])] for i in range(0, len(rle), 2)]
# print(rle)
ans = 0
for i in range(0, len(rle), 2):
    # print(rle[i], rle[i+1])
    ans += rle[i][1] * rle[i + 1][1]
    if i + 2 < len(rle):
        rle[i + 2][1] += rle[i][1]
    # print(f'{ans=}')
print(ans)


### FIXED CODE ###

import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


s = S()
ans = 0
w_cnt = 0
for i in range(len(s)):
    if s[i] == "W":
        ans += i - w_cnt  # その W の場所までにあった B の数
        w_cnt += 1

print(ans)
a = input()[0]
b = input()[1]
c = inpur()[2]
print(a+b+c)

### FIXED CODE ###

a = input()[0]
b = input()[1]
c = input()[2]
print(a+b+c)
x, y = map(int, input().split())
print("Yes" if x*2 <= y <= x*4 and x%2 = 0 else "No")

### FIXED CODE ###

x, y = map(int, input().split())
print("Yes" if x*2 <= y <= x*4 and y%2 == 0 else "No")
# -*- coding:UTF-8 -*-
import sys

print(int(sys.argv[1]) ** 3 + "\n")

### FIXED CODE ###

# -*- coding:UTF-8 -*-
print(int(input()) ** 3)
from datetime import datetime as dt
import datetime
d1=dt.fromisoformat('2019/04/30'.replace('/', '-'))
d2=dt.fromisoformat(input().replace('/', '-'))
delta=d1-d2
print('Heisei' if delta.days >= 0 else 'TBD')

### FIXED CODE ###

print('Heisei' if input()<='2019/04/30' else 'TBD')
N,M=map(int,input().split())

a,b=map(int,input().split())
A=[a]
B=[b]

L=[1 for i in range(N+1)]
L[a]=0
L[b]=0

l=[[]for i in range(N+1)]
for i in range(M-1):
    x,y=map(int,input().split())
    l[x].append(y)
    l[y].append(x)
def findA(a):
    for i in l[a]:
        if L[i]==0:
            pass
        else:
            L[i]=0
            A.append(i)
            findA(i)
    
def findB(b):
    for i in l[b]:
        if L[i]==0:
            pass
        else:
            L[i]=0
            B.append(i)
            findB(i)
findA(a)
findB(b)
#print(A)
#print(B)

A=A[::-1]
ans=A+B
print(len(ans))
ANS=str(ans[0])
for i in range(1,len(ans)):
    ANS+=" "+str(ans[i])
print(ANS)

### FIXED CODE ###

import sys
input=sys.stdin.readline

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

R=[1 for i in range(N+1)]
A,B=map(int,input().split())
R[A]=0
R[B]=0

L=[[]for i in range(N+1)]
L[A].append(B)
L[B].append(A)

for i in range(M-1):
    a,b=map(int,input().split())
    L[a].append(b)
    L[b].append(a)

l=[A]
P=A
#print(L)

for i in range(10**6):
    flag=0
    #print("P",L[P])
    for j in L[P]:
        #print("j",L,L[P],j,P)
        if R[j]==1:
            P=j
            R[j]=0
            l.append(j)
            flag+=1
            break
    if flag==0:
        break
#print(l)
r=[B]
P=B
for i in range(10**6):
    flag=0
    #print("P",L[P])
    for j in L[P]:
        #print("j",L,L[P],j,P)
        if R[j]==1:
            P=j
            R[j]=0
            r.append(j)
            flag+=1
            break
    if flag==0:
        break
#print(r)
l=l[::-1]
ans=l+r

ANS=str(ans[0])
for i in range(1,len(ans)):
    ANS+=" "+str(ans[i])
print(len(ans))
print(ANS)
import numpy as np
h,w = [int(i) for i in input().split()]
maximum = h+w
value = []
for i in range(h):
  value.append([0 if i == "#" else maximum for i in input().split()])
values = np.array(value)
for x in range(w-1):
  values[:,x+1] = np.minimum(values[:,x]+1,values[:,x+1])
for x in range(w-1,0,-1):
  values[:,x-1] = np.minimum(values[:,x]+1,values[:,x-1])
for y in range(h-1):
  values[y+1,:] = np.minimum(values[y,:]+1,values[y+1,:])
for y in range(h-1,0,-1):
  values[y-1,:] = np.minimum(values[y,:]+1,values[y-1,:])
print(values.min())

### FIXED CODE ###

import numpy as np
h,w = [int(i) for i in input().split()]
maximum = h+w
value = []
for i in range(h):
  value.append([0 if i == "#" else maximum for i in list(input())])
values = np.array(value)
for x in range(w-1):
  values[:,x+1] = np.minimum(values[:,x]+1,values[:,x+1])
for x in range(w-1,0,-1):
  values[:,x-1] = np.minimum(values[:,x]+1,values[:,x-1])
for y in range(h-1):
  values[y+1,:] = np.minimum(values[y,:]+1,values[y+1,:])
for y in range(h-1,0,-1):
  values[y-1,:] = np.minimum(values[y,:]+1,values[y-1,:])
print(values.max())
Ns = [input() for _ in range(int(input()))]
Ms = [input() for _ in range(int(input()))]
l = list(set(Ns))
print(max(0,max((Ns.count(l[i])-Ms.count(l[i]) for i in range(len(l))))))a

### FIXED CODE ###

Ns = [input() for _ in range(int(input()))]
Ms = [input() for _ in range(int(input()))]
l = list(set(Ns))
print(max(0,max((Ns.count(l[i])-Ms.count(l[i]) for i in range(len(l))))))
"""


N = input()
S = raw_input()

count_l = [0]
count_r = [0]


for i in range(N):
    if S[i] == 'W':
        tmp = count_l[i] + 1
    else:
        tmp = count_l[i]
    count_l.append(tmp)
    if S[N-1-i] == 'E':
        tmp = count_r[i] + 1
    else:
        tmp = count_r[i]
    count_r.append(tmp)

count_r.reverse()

Ans = count_l

for i in range(N+1):
    Ans[i] = count_r[i] + count_l[i]

print(min(Ans))

### FIXED CODE ###

N = input()
S = raw_input()

count_l = [0]
count_r = [0]


for i in range(N):
    if S[i] == 'W':
        tmp = count_l[i] + 1
    else:
        tmp = count_l[i]
    count_l.append(tmp)
    if S[N-1-i] == 'E':
        tmp = count_r[i] + 1
    else:
        tmp = count_r[i]
    count_r.append(tmp)

count_r.reverse()

Ans = count_l

for i in range(N+1):
    Ans[i] = count_r[i] + count_l[i]

print(min(Ans))
n = input();
k = input();

n = int(n);
k = int(k);

ans = n - k + 1;
print (ans);

### FIXED CODE ###

n,k=input().split()

n = int(n)
k = int(k)

ans = n - k + 1
print (ans)