N = int(eval(input()))

S = eval(input())



c = 0

for i in range(1, N):

    if S[i] == 'E':

        c += 1

dp = [{'i': 0, 'c': c}]



for i in range(1, N):

    c = dp[i-1]['c']

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

        c += 1

    if S[i] == 'E':

        c -= 1

    dp.append({'i': i, 'c': c})

dp.sort(key=lambda x:x['c'])

print((dp[0]['c']))
N = int(eval(input()))

S = eval(input())



c = 0

for i in range(1, N):

    if S[i] == 'E':

        c += 1

dp = [c]



for i in range(1, N):

    c = dp[i-1]

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

        c += 1

    if S[i] == 'E':

        c -= 1

    dp.append(c)

dp.sort()

print((dp[0]))
N = int(eval(input()))
S = eval(input())
c = 0
for i in range(1, N):
    if S[i] == "E":
        c += 1
dp = [{"i": 0, "c": c}]
for i in range(1, N):
    c = dp[i - 1]["c"]
    if S[i - 1] == "W":
        c += 1
    if S[i] == "E":
        c -= 1
    dp.append({"i": i, "c": c})
dp.sort(key=lambda x: x["c"])
print((dp[0]["c"]))

N = int(eval(input()))
S = eval(input())
c = 0
for i in range(1, N):
    if S[i] == "E":
        c += 1
dp = [c]
for i in range(1, N):
    c = dp[i - 1]
    if S[i - 1] == "W":
        c += 1
    if S[i] == "E":
        c -= 1
    dp.append(c)
dp.sort()
print((dp[0]))

-dp = [{"i": 0, "c": c}] +dp = [c] -    c = dp[i - 1]["c"] +    c = dp[i - 1] -    dp.append({"i": i, "c": c}) -dp.sort(key=lambda x: x["c"]) -print((dp[0]["c"])) +    dp.append(c) +dp.sort() +print((dp[0]))