n = int(eval(input()))

s = eval(input())



c_e = [0]

t = 0

for c in s:

    if c == 'E':

        t += 1

    c_e.append(t)



ans = n

for leader in range(n):

    ans = min(ans, (leader - c_e[leader]) + (c_e[n] - c_e[leader + 1]))

print(ans)

# 累積和のリストは、1-indexed

def main():

    n = int(eval(input()))

    a = [c == 'E' for c in eval(input())]



    def accumulate(a):

        s = 0

        yield s

        for x in a:

            s += x

            yield s



    *acc_e, = accumulate(a)



    ans = 1 << 30

    for i in range(n):

        ans = min(ans, (i - acc_e[i]) + (acc_e[n] - acc_e[i + 1]))



    print(ans)





if __name__ == '__main__':

    main()

n = int(eval(input()))
s = eval(input())
c_e = [0]
t = 0
for c in s:
    if c == "E":
        t += 1
    c_e.append(t)
ans = n
for leader in range(n):
    ans = min(ans, (leader - c_e[leader]) + (c_e[n] - c_e[leader + 1]))
print(ans)
# 累積和のリストは、1-indexed

def main():
    n = int(eval(input()))
    a = [c == "E" for c in eval(input())]

    def accumulate(a):
        s = 0
        yield s
        for x in a:
            s += x
            yield s

    (*acc_e,) = accumulate(a)
    ans = 1 << 30
    for i in range(n):
        ans = min(ans, (i - acc_e[i]) + (acc_e[n] - acc_e[i + 1]))
    print(ans)


if __name__ == "__main__":
    main()

-n = int(eval(input())) -s = eval(input()) -c_e = [0] -t = 0 -for c in s: -    if c == "E": -        t += 1 -    c_e.append(t) -ans = n -for leader in range(n): -    ans = min(ans, (leader - c_e[leader]) + (c_e[n] - c_e[leader + 1])) -print(ans) -# 累積和のリストは、1-indexed +def main(): +    n = int(eval(input())) +    a = [c == "E" for c in eval(input())] + +    def accumulate(a): +        s = 0 +        yield s +        for x in a: +            s += x +            yield s + +    (*acc_e,) = accumulate(a) +    ans = 1 << 30 +    for i in range(n): +        ans = min(ans, (i - acc_e[i]) + (acc_e[n] - acc_e[i + 1])) +    print(ans) + + +if __name__ == "__main__": +    main()