N = int(eval(input()))

S = eval(input())



def f(S):

  count = {'W': 0, 'E': 0}

  yield count['W'], count['E']

  for c in S:

    count[c] += 1

    yield count['W'], count['E']



count = list(f(S))

print((min([count[i-1][0] + count[-1][1] - count[i][1] for i in range(1, N+1)])))

N = int(eval(input()))

S = eval(input())



def f(S):

  count = S.count('E')

  for s in S:

    if s == 'E':

      count += -1

    yield count

    if s == 'W':

      count += 1



print((min(list(f(S)))))

N = int(eval(input()))
S = eval(input())


def f(S):
    count = {"W": 0, "E": 0}
    yield count["W"], count["E"]
    for c in S:
        count[c] += 1
        yield count["W"], count["E"]


count = list(f(S))
print((min([count[i - 1][0] + count[-1][1] - count[i][1] for i in range(1, N + 1)])))

N = int(eval(input()))
S = eval(input())


def f(S):
    count = S.count("E")
    for s in S:
        if s == "E":
            count += -1
        yield count
        if s == "W":
            count += 1


print((min(list(f(S)))))

-    count = {"W": 0, "E": 0} -    yield count["W"], count["E"] -    for c in S: -        count[c] += 1 -        yield count["W"], count["E"] +    count = S.count("E") +    for s in S: +        if s == "E": +            count += -1 +        yield count +        if s == "W": +            count += 1 -count = list(f(S)) -print((min([count[i - 1][0] + count[-1][1] - count[i][1] for i in range(1, N + 1)]))) +print((min(list(f(S)))))