N = int(eval(input()))

S = eval(input())

min_turn = 300000

wnum = 0

for i in range(N):

    if i == 0:

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

    if (1 <= i) and (S[i] == 'E'):

        enum -= 1

    if (1 <= i) and (S[i-1] == 'W'):

        wnum += 1

    turn = enum + wnum

    if min_turn > turn:

        min_turn = turn

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

S = eval(input())

turn = S.count('E')

min_turn = 300000

for i in range(N):

    if S[i] == 'E':

        turn -= 1

    if (S[i-1] == 'W') and (1 <= i):

        turn += 1

    if min_turn > turn:

        min_turn = turn

print(min_turn)
N = int(eval(input()))
S = eval(input())
min_turn = 300000
wnum = 0
for i in range(N):
    if i == 0:
        enum = S[1:].count("E")
    if (1 <= i) and (S[i] == "E"):
        enum -= 1
    if (1 <= i) and (S[i - 1] == "W"):
        wnum += 1
    turn = enum + wnum
    if min_turn > turn:
        min_turn = turn
print(min_turn)

N = int(eval(input()))
S = eval(input())
turn = S.count("E")
min_turn = 300000
for i in range(N):
    if S[i] == "E":
        turn -= 1
    if (S[i - 1] == "W") and (1 <= i):
        turn += 1
    if min_turn > turn:
        min_turn = turn
print(min_turn)

+turn = S.count("E") -wnum = 0 -    if i == 0: -        enum = S[1:].count("E") -    if (1 <= i) and (S[i] == "E"): -        enum -= 1 -    if (1 <= i) and (S[i - 1] == "W"): -        wnum += 1 -    turn = enum + wnum +    if S[i] == "E": +        turn -= 1 +    if (S[i - 1] == "W") and (1 <= i): +        turn += 1