import sys



n = int(sys.stdin.readline().rstrip())

s = sys.stdin.readline().rstrip()



def main():

    l = 0

    r = s.count('E')

    res = r

    for i in range(n):

        cur = s[i]

        if cur == 'E':

            r -= 1

        res = min(res, l + r)

        if cur == 'W':

            l += 1

    return res



if __name__ == '__main__':

    ans = main()

    print(ans)
import sys



n, s = sys.stdin.read().split()



def main():

    cnt = s.count('E')

    cur = 'E'

    res = [cnt]

    for c in s:

        if cur == 'W': cnt += 1

        if c == 'E': cnt -= 1

        res.append(cnt)

        cur = c

    print((min(res)))

    

if __name__ ==  '__main__':

    main()
import sys

n = int(sys.stdin.readline().rstrip())
s = sys.stdin.readline().rstrip()


def main():
    l = 0
    r = s.count("E")
    res = r
    for i in range(n):
        cur = s[i]
        if cur == "E":
            r -= 1
        res = min(res, l + r)
        if cur == "W":
            l += 1
    return res


if __name__ == "__main__":
    ans = main()
    print(ans)

import sys

n, s = sys.stdin.read().split()


def main():
    cnt = s.count("E")
    cur = "E"
    res = [cnt]
    for c in s:
        if cur == "W":
            cnt += 1
        if c == "E":
            cnt -= 1
        res.append(cnt)
        cur = c
    print((min(res)))


if __name__ == "__main__":
    main()

-n = int(sys.stdin.readline().rstrip()) -s = sys.stdin.readline().rstrip() +n, s = sys.stdin.read().split() -    l = 0 -    r = s.count("E") -    res = r -    for i in range(n): -        cur = s[i] -        if cur == "E": -            r -= 1 -        res = min(res, l + r) +    cnt = s.count("E") +    cur = "E" +    res = [cnt] +    for c in s: -            l += 1 -    return res +            cnt += 1 +        if c == "E": +            cnt -= 1 +        res.append(cnt) +        cur = c +    print((min(res))) -    ans = main() -    print(ans) +    main()