

N = int(eval(input()))

S = eval(input())



tmp = 0



for s in S[1:]:

    if s == 'E':

        tmp += 1

  



minimum = tmp



for i in range(1, N):

    if S[i-1] == 'W':

        tmp += 1

    if S[i] == 'E':

        tmp -= 1

    minimum = min(tmp, minimum)



print(minimum)

N = int(eval(input()))

S = eval(input())



tmp = S[1:].count('E')

  

minimum = tmp



for i in range(1, N):

    if S[i-1] == 'W':

        tmp += 1

    if S[i] == 'E':

        tmp -= 1

    minimum = min(tmp, minimum)



print(minimum)

N = int(eval(input()))
S = eval(input())
tmp = 0
for s in S[1:]:
    if s == "E":
        tmp += 1
minimum = tmp
for i in range(1, N):
    if S[i - 1] == "W":
        tmp += 1
    if S[i] == "E":
        tmp -= 1
    minimum = min(tmp, minimum)
print(minimum)

N = int(eval(input()))
S = eval(input())
tmp = S[1:].count("E")
minimum = tmp
for i in range(1, N):
    if S[i - 1] == "W":
        tmp += 1
    if S[i] == "E":
        tmp -= 1
    minimum = min(tmp, minimum)
print(minimum)

-tmp = 0 -for s in S[1:]: -    if s == "E": -        tmp += 1 +tmp = S[1:].count("E")