def solve(string):

    n, s = string.split()

    n = int(n)

    es = {i for i, _s in enumerate(s) if _s == "E"}

    num_e = len(es)

    num_w = n - num_e

    count_e = 0

    count_w = 0



    ans = n

    for i, _s in enumerate(s):

        tmp = [count_e, count_w]

        if i in es:

            count_e += 1

        else:

            count_w += 1

        tmp += [num_e - count_e, num_w - count_w]

        ans = min(ans, tmp[1] + tmp[2])

    return str(ans)





if __name__ == '__main__':

    print((solve('\n'.join([eval(input()), eval(input())]))))

def solve(string):

    n, s = string.split()

    n = int(n)

    es = {i for i, _s in enumerate(s) if _s == "E"}

    num_e = len(es)

    count_e = 0

    count_w = 0



    ans = n

    for i, _s in enumerate(s):

        tmp = count_w

        if i in es:

            count_e += 1

        else:

            count_w += 1

        tmp += num_e - count_e

        ans = min(ans, tmp)

    return str(ans)





if __name__ == '__main__':

    print((solve('\n'.join([eval(input()), eval(input())]))))

def solve(string):
    n, s = string.split()
    n = int(n)
    es = {i for i, _s in enumerate(s) if _s == "E"}
    num_e = len(es)
    num_w = n - num_e
    count_e = 0
    count_w = 0
    ans = n
    for i, _s in enumerate(s):
        tmp = [count_e, count_w]
        if i in es:
            count_e += 1
        else:
            count_w += 1
        tmp += [num_e - count_e, num_w - count_w]
        ans = min(ans, tmp[1] + tmp[2])
    return str(ans)


if __name__ == "__main__":
    print((solve("\n".join([eval(input()), eval(input())]))))

def solve(string):
    n, s = string.split()
    n = int(n)
    es = {i for i, _s in enumerate(s) if _s == "E"}
    num_e = len(es)
    count_e = 0
    count_w = 0
    ans = n
    for i, _s in enumerate(s):
        tmp = count_w
        if i in es:
            count_e += 1
        else:
            count_w += 1
        tmp += num_e - count_e
        ans = min(ans, tmp)
    return str(ans)


if __name__ == "__main__":
    print((solve("\n".join([eval(input()), eval(input())]))))

-    num_w = n - num_e -        tmp = [count_e, count_w] +        tmp = count_w -        tmp += [num_e - count_e, num_w - count_w] -        ans = min(ans, tmp[1] + tmp[2]) +        tmp += num_e - count_e +        ans = min(ans, tmp)