n = int(eval(input()))

S = eval(input())

WE = [[] for _ in range(n)]

w = 0

e = 0



for i in range(n):

    if S[i] == "W":

        w += 1

    else:

        e += 1

    

    WE[i].append(w)

    WE[i].append(e)

    

ans = WE[n-1][1] - WE[0][1]



for i in range(1,n):

    res = WE[i-1][0] + (WE[n-1][1] - WE[i][1])

    ans = min(ans,res)

    

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

S = eval(input())

W = [0] * (n+1)

w = 0

ans = float("inf")



for i in range(n):

    if S[i] == "W":

        w += 1

    

    W[i+1] = w

    

for i in range(n):

    res = W[i] + ((n-W[n]) - (i+1-W[i+1]))

    ans = min(ans,res)

    

print(ans)
n = int(eval(input()))
S = eval(input())
WE = [[] for _ in range(n)]
w = 0
e = 0
for i in range(n):
    if S[i] == "W":
        w += 1
    else:
        e += 1
    WE[i].append(w)
    WE[i].append(e)
ans = WE[n - 1][1] - WE[0][1]
for i in range(1, n):
    res = WE[i - 1][0] + (WE[n - 1][1] - WE[i][1])
    ans = min(ans, res)
print(ans)

n = int(eval(input()))
S = eval(input())
W = [0] * (n + 1)
w = 0
ans = float("inf")
for i in range(n):
    if S[i] == "W":
        w += 1
    W[i + 1] = w
for i in range(n):
    res = W[i] + ((n - W[n]) - (i + 1 - W[i + 1]))
    ans = min(ans, res)
print(ans)

-WE = [[] for _ in range(n)] +W = [0] * (n + 1) -e = 0 +ans = float("inf") -    else: -        e += 1 -    WE[i].append(w) -    WE[i].append(e) -ans = WE[n - 1][1] - WE[0][1] -for i in range(1, n): -    res = WE[i - 1][0] + (WE[n - 1][1] - WE[i][1]) +    W[i + 1] = w +for i in range(n): +    res = W[i] + ((n - W[n]) - (i + 1 - W[i + 1]))