N = int(eval(input()))

S = eval(input())



cnt_W = [0]*N #西を向いている人の累積和を求める

if S[0] == 'W':

    cnt_W[0] = 1



for i in range(1, N):

    if S[i]=="W":

        cnt_W[i] += cnt_W[i-1] + 1

    else:

        cnt_W[i] = cnt_W[i-1]



most_E = cnt_W[-1] #全体で西を向いている人数

#print(most_E)

ans = float('inf')

for i in range(N):

    tmp = 0

    if i == 0:

        if S[i] == "W":

            tmp = (N-most_E)

        else:

            tmp = (N-most_E)-1

        #print(tmp)

    elif i == N-1:

        if S[i] == "W":

            tmp = most_E-1

        else:

            tmp = most_E

        #print(tmp)

    else:

        tmp = cnt_W[i-1] + (N-most_E) - (i+1-cnt_W[i])

        #print(tmp)



    ans = min(ans, tmp)

print(ans)

N = int(eval(input()))

S = eval(input())



cnt_W = [0]*N #西を向いている人の累積和を求める

if S[0] == 'W':

    cnt_W[0] = 1



for i in range(1, N):

    if S[i]=="W":

        cnt_W[i] += cnt_W[i-1] + 1

    else:

        cnt_W[i] = cnt_W[i-1]



most_E = cnt_W[-1] #全体で西を向いている人数

ans = []

for i in range(N):

    if i == 0:

        if S[i] == "W":

            ans.append(N-most_E)

        else:

            ans.append((N-most_E)-1)

    elif i == N-1:

        if S[i] == "W":

            ans.append(most_E-1)

        else:

            ans.append(most_E)

    else:

        ans.append(cnt_W[i-1] + (N-most_E) - (i+1-cnt_W[i]))



print((min(ans)))

N = int(eval(input()))
S = eval(input())
cnt_W = [0] * N  # 西を向いている人の累積和を求める
if S[0] == "W":
    cnt_W[0] = 1
for i in range(1, N):
    if S[i] == "W":
        cnt_W[i] += cnt_W[i - 1] + 1
    else:
        cnt_W[i] = cnt_W[i - 1]
most_E = cnt_W[-1]  # 全体で西を向いている人数
# print(most_E)
ans = float("inf")
for i in range(N):
    tmp = 0
    if i == 0:
        if S[i] == "W":
            tmp = N - most_E
        else:
            tmp = (N - most_E) - 1
        # print(tmp)
    elif i == N - 1:
        if S[i] == "W":
            tmp = most_E - 1
        else:
            tmp = most_E
        # print(tmp)
    else:
        tmp = cnt_W[i - 1] + (N - most_E) - (i + 1 - cnt_W[i])
        # print(tmp)
    ans = min(ans, tmp)
print(ans)

N = int(eval(input()))
S = eval(input())
cnt_W = [0] * N  # 西を向いている人の累積和を求める
if S[0] == "W":
    cnt_W[0] = 1
for i in range(1, N):
    if S[i] == "W":
        cnt_W[i] += cnt_W[i - 1] + 1
    else:
        cnt_W[i] = cnt_W[i - 1]
most_E = cnt_W[-1]  # 全体で西を向いている人数
ans = []
for i in range(N):
    if i == 0:
        if S[i] == "W":
            ans.append(N - most_E)
        else:
            ans.append((N - most_E) - 1)
    elif i == N - 1:
        if S[i] == "W":
            ans.append(most_E - 1)
        else:
            ans.append(most_E)
    else:
        ans.append(cnt_W[i - 1] + (N - most_E) - (i + 1 - cnt_W[i]))
print((min(ans)))

-# print(most_E) -ans = float("inf") +ans = [] -    tmp = 0 -            tmp = N - most_E +            ans.append(N - most_E) -            tmp = (N - most_E) - 1 -        # print(tmp) +            ans.append((N - most_E) - 1) -            tmp = most_E - 1 +            ans.append(most_E - 1) -            tmp = most_E -        # print(tmp) +            ans.append(most_E) -        tmp = cnt_W[i - 1] + (N - most_E) - (i + 1 - cnt_W[i]) -        # print(tmp) -    ans = min(ans, tmp) -print(ans) +        ans.append(cnt_W[i - 1] + (N - most_E) - (i + 1 - cnt_W[i])) +print((min(ans)))