def main():

    n = int(eval(input()))

    ss = list(eval(input()))



    ans = float("inf")

    ans = [0] * n

    cum_sum_w = [0] * (n+1)

    cum_sum_e = [0] * (n+1)

    for i in range(n):

        if ss[i] == 'W':

            add = 1

        else:

            add = 0

        cum_sum_w[i+1] = cum_sum_w[i] + add

    for i in range(n):

        if ss[i] == 'E':

            add = 1

        else:

            add = 0

        cum_sum_e[i+1] = cum_sum_e[i] + add

    for i in range(n):

        ans[i] = cum_sum_w[i] + (cum_sum_e[n] - cum_sum_e[i+1])

    print((min(ans)))





if __name__ == "__main__":

    main()

def main():

    n = int(eval(input()))

    ss = list(eval(input()))

    num_sum = [0]*n

    west_sum = 0

    east_sum = 0

    for i in range(1, n):

        if ss[i-1] == 'W':

            west_sum += 1

        num_sum[i] += west_sum



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

        if ss[i+1] == 'E':

            east_sum += 1

        num_sum[i] += east_sum



    ans = min(num_sum)

    print(ans)



if __name__ == "__main__":

    main()

def main():
    n = int(eval(input()))
    ss = list(eval(input()))
    ans = float("inf")
    ans = [0] * n
    cum_sum_w = [0] * (n + 1)
    cum_sum_e = [0] * (n + 1)
    for i in range(n):
        if ss[i] == "W":
            add = 1
        else:
            add = 0
        cum_sum_w[i + 1] = cum_sum_w[i] + add
    for i in range(n):
        if ss[i] == "E":
            add = 1
        else:
            add = 0
        cum_sum_e[i + 1] = cum_sum_e[i] + add
    for i in range(n):
        ans[i] = cum_sum_w[i] + (cum_sum_e[n] - cum_sum_e[i + 1])
    print((min(ans)))


if __name__ == "__main__":
    main()

def main():
    n = int(eval(input()))
    ss = list(eval(input()))
    num_sum = [0] * n
    west_sum = 0
    east_sum = 0
    for i in range(1, n):
        if ss[i - 1] == "W":
            west_sum += 1
        num_sum[i] += west_sum
    for i in range(n - 2, -1, -1):
        if ss[i + 1] == "E":
            east_sum += 1
        num_sum[i] += east_sum
    ans = min(num_sum)
    print(ans)


if __name__ == "__main__":
    main()

-    ans = float("inf") -    ans = [0] * n -    cum_sum_w = [0] * (n + 1) -    cum_sum_e = [0] * (n + 1) -    for i in range(n): -        if ss[i] == "W": -            add = 1 -        else: -            add = 0 -        cum_sum_w[i + 1] = cum_sum_w[i] + add -    for i in range(n): -        if ss[i] == "E": -            add = 1 -        else: -            add = 0 -        cum_sum_e[i + 1] = cum_sum_e[i] + add -    for i in range(n): -        ans[i] = cum_sum_w[i] + (cum_sum_e[n] - cum_sum_e[i + 1]) -    print((min(ans))) +    num_sum = [0] * n +    west_sum = 0 +    east_sum = 0 +    for i in range(1, n): +        if ss[i - 1] == "W": +            west_sum += 1 +        num_sum[i] += west_sum +    for i in range(n - 2, -1, -1): +        if ss[i + 1] == "E": +            east_sum += 1 +        num_sum[i] += east_sum +    ans = min(num_sum) +    print(ans)