def main():

    N = int(eval(input()))

    S = eval(input())

    ec = S.count('E')

    tec = ec

    for k in S:

        if k == 'E':

            tec -= 1

        else:

            tec += 1

        ec = min(ec, tec)

    print(ec)



if __name__ == '__main__':

    main()
def main():

    N = int(eval(input()))

    S = eval(input())

    ec = S.count('E')

    wc = 0

    min = ec

    for k in S:

        if k == 'E':

            ec -= 1

        else:

            wc += 1

        if min > ec + wc: min = ec + wc

    print(min)



if __name__ == '__main__':

    main()
def main():
    N = int(eval(input()))
    S = eval(input())
    ec = S.count("E")
    tec = ec
    for k in S:
        if k == "E":
            tec -= 1
        else:
            tec += 1
        ec = min(ec, tec)
    print(ec)


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    S = eval(input())
    ec = S.count("E")
    wc = 0
    min = ec
    for k in S:
        if k == "E":
            ec -= 1
        else:
            wc += 1
        if min > ec + wc:
            min = ec + wc
    print(min)


if __name__ == "__main__":
    main()

-    tec = ec +    wc = 0 +    min = ec -            tec -= 1 +            ec -= 1 -            tec += 1 -        ec = min(ec, tec) -    print(ec) +            wc += 1 +        if min > ec + wc: +            min = ec + wc +    print(min)