def main():

    N = int(eval(input()))

    S = list(eval(input()))

    S = list([0 if x == "W" else 1 for x in S])



    E = 0

    W = sum(S[1:N])



    p = W

    for i in range(1, N):

        E += 1 - S[i-1]

        W -= S[i]

        ss = E + W

        if ss < p:

            p = ss



    print(p)





main()

def solver():

    N = int(eval(input()))

    S = list(eval(input()))



    rE = S.count('E')  # リーダーより右にいる人の数

    rW = N - rE



    lE = 0

    lW = 0



    c = N



    for s in S:

        if s == 'E':

            rE -= 1

            f = 1

        else:

            rW -= 1

            f = -1



        candidate = rE + lW

        # print(candidate)



        if candidate < c:

            c = candidate



        if f == 1:

            lE += 1

        else:

            lW += 1



    print(c)





solver()

def main():
    N = int(eval(input()))
    S = list(eval(input()))
    S = list([0 if x == "W" else 1 for x in S])
    E = 0
    W = sum(S[1:N])
    p = W
    for i in range(1, N):
        E += 1 - S[i - 1]
        W -= S[i]
        ss = E + W
        if ss < p:
            p = ss
    print(p)


main()

def solver():
    N = int(eval(input()))
    S = list(eval(input()))
    rE = S.count("E")  # リーダーより右にいる人の数
    rW = N - rE
    lE = 0
    lW = 0
    c = N
    for s in S:
        if s == "E":
            rE -= 1
            f = 1
        else:
            rW -= 1
            f = -1
        candidate = rE + lW
        # print(candidate)
        if candidate < c:
            c = candidate
        if f == 1:
            lE += 1
        else:
            lW += 1
    print(c)


solver()

-def main(): +def solver(): -    S = list([0 if x == "W" else 1 for x in S]) -    E = 0 -    W = sum(S[1:N]) -    p = W -    for i in range(1, N): -        E += 1 - S[i - 1] -        W -= S[i] -        ss = E + W -        if ss < p: -            p = ss -    print(p) +    rE = S.count("E")  # リーダーより右にいる人の数 +    rW = N - rE +    lE = 0 +    lW = 0 +    c = N +    for s in S: +        if s == "E": +            rE -= 1 +            f = 1 +        else: +            rW -= 1 +            f = -1 +        candidate = rE + lW +        # print(candidate) +        if candidate < c: +            c = candidate +        if f == 1: +            lE += 1 +        else: +            lW += 1 +    print(c) -main() +solver()