# coding:utf-8



INF = float('inf')





N = int(eval(input()))

S = eval(input())



num_E = 0

num_W = 0

for s in S:

    if s == 'E':

        num_E += 1

    else:

        num_W += 1



e = num_E

w = num_W

ans = INF

for s in S:

    cost = 0

    if s == 'E':

        e -= 1

        cost = e + (num_W - w)

    else:

        w -= 1

        cost = e + (num_W - w - 1)

    ans = min(ans, cost)



print(ans)

# coding:utf-8



INF = float('inf')





N = int(eval(input()))

S = eval(input())



num_E = S[:].count('E')

num_W = S[:].count('W')





e = num_E

w = num_W

ans = INF

for s in S:

    cost = 0

    if s == 'E':

        e -= 1

        cost = e + (num_W - w)

    else:

        w -= 1

        cost = e + (num_W - w - 1)

    ans = min(ans, cost)



print(ans)
# coding:utf-8
INF = float("inf")
N = int(eval(input()))
S = eval(input())
num_E = 0
num_W = 0
for s in S:
    if s == "E":
        num_E += 1
    else:
        num_W += 1
e = num_E
w = num_W
ans = INF
for s in S:
    cost = 0
    if s == "E":
        e -= 1
        cost = e + (num_W - w)
    else:
        w -= 1
        cost = e + (num_W - w - 1)
    ans = min(ans, cost)
print(ans)

# coding:utf-8
INF = float("inf")
N = int(eval(input()))
S = eval(input())
num_E = S[:].count("E")
num_W = S[:].count("W")
e = num_E
w = num_W
ans = INF
for s in S:
    cost = 0
    if s == "E":
        e -= 1
        cost = e + (num_W - w)
    else:
        w -= 1
        cost = e + (num_W - w - 1)
    ans = min(ans, cost)
print(ans)

-num_E = 0 -num_W = 0 -for s in S: -    if s == "E": -        num_E += 1 -    else: -        num_W += 1 +num_E = S[:].count("E") +num_W = S[:].count("W")