n = int(eval(input()))



s = eval(input())





a = [0] * (n+1)

b = [0] * (n+1)

ans = 3 * 10 ** 5



aN = s.count("E")

for i in range(n):

  if s[i] == "E":

    a[i+1] = a[i] + 1

    b[i+1] = b[i]

  else:

    a[i+1] = a[i]

    b[i+1] = b[i] + 1

  #print(ans, aN-a[i+1]+b[i])  

  ans = min(ans, aN-a[i+1]+b[i])

  

  

  

print((ans))
N = int(eval(input()))



S = eval(input())



re = [0] * N # 右からの累積和

le = [0] * N # からの累積和

INF = float("inf")

for i in range(1,N):

    

    if S[i-1] == "E":

        le[i] = le[i-1] + 1

    else:

        le[i] = le[i-1]



    if S[N-i] == "E":

        re[N-1-i] = re[N-i] + 1

    else:

        re[N-1-i] = re[N-i]



ans = [INF] * N



for i in range(N):

    ans[i] = (i - le[i]) + (re[i])



print((min(ans)))
n = int(eval(input()))
s = eval(input())
a = [0] * (n + 1)
b = [0] * (n + 1)
ans = 3 * 10**5
aN = s.count("E")
for i in range(n):
    if s[i] == "E":
        a[i + 1] = a[i] + 1
        b[i + 1] = b[i]
    else:
        a[i + 1] = a[i]
        b[i + 1] = b[i] + 1
    # print(ans, aN-a[i+1]+b[i])
    ans = min(ans, aN - a[i + 1] + b[i])
print((ans))

N = int(eval(input()))
S = eval(input())
re = [0] * N  # 右からの累積和
le = [0] * N  # からの累積和
INF = float("inf")
for i in range(1, N):
    if S[i - 1] == "E":
        le[i] = le[i - 1] + 1
    else:
        le[i] = le[i - 1]
    if S[N - i] == "E":
        re[N - 1 - i] = re[N - i] + 1
    else:
        re[N - 1 - i] = re[N - i]
ans = [INF] * N
for i in range(N):
    ans[i] = (i - le[i]) + (re[i])
print((min(ans)))

-n = int(eval(input())) -s = eval(input()) -a = [0] * (n + 1) -b = [0] * (n + 1) -ans = 3 * 10**5 -aN = s.count("E") -for i in range(n): -    if s[i] == "E": -        a[i + 1] = a[i] + 1 -        b[i + 1] = b[i] +N = int(eval(input())) +S = eval(input()) +re = [0] * N  # 右からの累積和 +le = [0] * N  # からの累積和 +INF = float("inf") +for i in range(1, N): +    if S[i - 1] == "E": +        le[i] = le[i - 1] + 1 -        a[i + 1] = a[i] -        b[i + 1] = b[i] + 1 -    # print(ans, aN-a[i+1]+b[i]) -    ans = min(ans, aN - a[i + 1] + b[i]) -print((ans)) +        le[i] = le[i - 1] +    if S[N - i] == "E": +        re[N - 1 - i] = re[N - i] + 1 +    else: +        re[N - 1 - i] = re[N - i] +ans = [INF] * N +for i in range(N): +    ans[i] = (i - le[i]) + (re[i]) +print((min(ans)))