N = int(eval(input()))

S = eval(input())



A = []

w = 0

for si in S:

    if si == 'W':

        w += 1

    A.append([w])



# E = []

e = 0

for i, si in enumerate(S[::-1]):

    if si == 'E':

        e += 1

    # E.append(e)

    A[-1 * i - 1].append(e)



# E = E[::-1]

# for i in range(N):

#     A[i][1] = E[i]



ans = N

for ai in A:

    ans = min(ans, ai[0] + ai[1] - 1)

print(ans)
N = int(eval(input()))

S = eval(input())

ans = N



A = []

w = 0

for si in S:

    if si == 'W':

        w += 1

    A.append(w)



e = 0

for i, si in enumerate(S[::-1]):

    if si == 'E':

        e += 1

    ans = min(ans, A[-1 * i - 1] + e - 1)



print(ans)
N = int(eval(input()))
S = eval(input())
A = []
w = 0
for si in S:
    if si == "W":
        w += 1
    A.append([w])
# E = []
e = 0
for i, si in enumerate(S[::-1]):
    if si == "E":
        e += 1
    # E.append(e)
    A[-1 * i - 1].append(e)
# E = E[::-1]
# for i in range(N):
#     A[i][1] = E[i]
ans = N
for ai in A:
    ans = min(ans, ai[0] + ai[1] - 1)
print(ans)

N = int(eval(input()))
S = eval(input())
ans = N
A = []
w = 0
for si in S:
    if si == "W":
        w += 1
    A.append(w)
e = 0
for i, si in enumerate(S[::-1]):
    if si == "E":
        e += 1
    ans = min(ans, A[-1 * i - 1] + e - 1)
print(ans)

+ans = N -    A.append([w]) -# E = [] +    A.append(w) -    # E.append(e) -    A[-1 * i - 1].append(e) -# E = E[::-1] -# for i in range(N): -#     A[i][1] = E[i] -ans = N -for ai in A: -    ans = min(ans, ai[0] + ai[1] - 1) +    ans = min(ans, A[-1 * i - 1] + e - 1)