N = int(eval(input()))

S = list(eval(input()))



cntW = 0

cntE = 0

sumW =[]

sumE = []

num_of_turn = []



for i in range(N):

    if S[i] == 'W':

        cntW += 1

    elif S[i] == 'E':

        cntE += 1

    sumW.append(cntW)

    sumE.append(cntE)



num_of_turn.append(sumE[N - 1] - sumE[0])



for i in range(1, N - 1):

    num_of_turn.append(sumW[i - 1] + sumE[N - 1] - sumE[i])



num_of_turn.append(sumW[N - 1])



print((min(num_of_turn)))

N = int(eval(input()))

S = list(eval(input()))



numE = S.count('E')

numTurn = numE

numW = 0



for i in range(N):

    if S[i] == 'E':

        numE -= 1

    else:

        numW += 1

    if numTurn > numE + numW:

        numTurn = numE + numW



print(numTurn)

N = int(eval(input()))
S = list(eval(input()))
cntW = 0
cntE = 0
sumW = []
sumE = []
num_of_turn = []
for i in range(N):
    if S[i] == "W":
        cntW += 1
    elif S[i] == "E":
        cntE += 1
    sumW.append(cntW)
    sumE.append(cntE)
num_of_turn.append(sumE[N - 1] - sumE[0])
for i in range(1, N - 1):
    num_of_turn.append(sumW[i - 1] + sumE[N - 1] - sumE[i])
num_of_turn.append(sumW[N - 1])
print((min(num_of_turn)))

N = int(eval(input()))
S = list(eval(input()))
numE = S.count("E")
numTurn = numE
numW = 0
for i in range(N):
    if S[i] == "E":
        numE -= 1
    else:
        numW += 1
    if numTurn > numE + numW:
        numTurn = numE + numW
print(numTurn)

-cntW = 0 -cntE = 0 -sumW = [] -sumE = [] -num_of_turn = [] +numE = S.count("E") +numTurn = numE +numW = 0 -    if S[i] == "W": -        cntW += 1 -    elif S[i] == "E": -        cntE += 1 -    sumW.append(cntW) -    sumE.append(cntE) -num_of_turn.append(sumE[N - 1] - sumE[0]) -for i in range(1, N - 1): -    num_of_turn.append(sumW[i - 1] + sumE[N - 1] - sumE[i]) -num_of_turn.append(sumW[N - 1]) -print((min(num_of_turn))) +    if S[i] == "E": +        numE -= 1 +    else: +        numW += 1 +    if numTurn > numE + numW: +        numTurn = numE + numW +print(numTurn)