import sys

input=sys.stdin.readline



def main():

    N = int(eval(input()))

    S = input().strip()

    

    E = [0]*N

    W = [0]*N

    for i in range(1,N):

        E[i] = E[i-1]

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

            E[i] += 1

    for i in range(N-2,-1,-1):

        W[i] = W[i+1]

        if S[i+1] == "E":

            W[i] += 1



    X = [0]*N

    for i in range(N):

        X[i] = W[i] + E[i]

    print((min(X)))

if __name__ == '__main__':

    main()

import sys

input=sys.stdin.readline



def main():

    N = int(eval(input()))

    S = input().strip()

    

    E = [0]*N

    e = 0

    for i in range(0,N):

        E[i] = e

        if S[i] == "W":

            e += 1

    W = [0]*N

    w = 0

    for i in range(N-1,-1,-1):

        W[i] = w

        if S[i] == "E":

            w += 1



    X = [0]*N

    for i in range(N):

        X[i] = W[i] + E[i]

    print((min(X)))

if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    S = input().strip()
    E = [0] * N
    W = [0] * N
    for i in range(1, N):
        E[i] = E[i - 1]
        if S[i - 1] == "W":
            E[i] += 1
    for i in range(N - 2, -1, -1):
        W[i] = W[i + 1]
        if S[i + 1] == "E":
            W[i] += 1
    X = [0] * N
    for i in range(N):
        X[i] = W[i] + E[i]
    print((min(X)))


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    S = input().strip()
    E = [0] * N
    e = 0
    for i in range(0, N):
        E[i] = e
        if S[i] == "W":
            e += 1
    W = [0] * N
    w = 0
    for i in range(N - 1, -1, -1):
        W[i] = w
        if S[i] == "E":
            w += 1
    X = [0] * N
    for i in range(N):
        X[i] = W[i] + E[i]
    print((min(X)))


if __name__ == "__main__":
    main()

+    e = 0 +    for i in range(0, N): +        E[i] = e +        if S[i] == "W": +            e += 1 -    for i in range(1, N): -        E[i] = E[i - 1] -        if S[i - 1] == "W": -            E[i] += 1 -    for i in range(N - 2, -1, -1): -        W[i] = W[i + 1] -        if S[i + 1] == "E": -            W[i] += 1 +    w = 0 +    for i in range(N - 1, -1, -1): +        W[i] = w +        if S[i] == "E": +            w += 1