def 解():

    iN = int(eval(input()))

    sS = input().rstrip()



    aE= [0]*iN #東向かされる人

    aW= [0]*iN #西向かされる人

    for i in range(1,iN):

        if sS[i-1] == "W":

            aE[i] = aE[i-1]+1

        else:

            aE[i] = aE[i-1]

    iMinCost = aE[iN-1]

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

        if sS[i+1]=="E":

            aW[i] = aW[i+1]+1

        else:

            aW[i] = aW[i+1]

        iMinCost = min(iMinCost,aW[i]+aE[i])

    print(iMinCost)



解()

def 解():

    iN = int(eval(input()))

    sS = input().rstrip()



    aE= [0]*iN #東向かされる人

    for i in range(1,iN):

        if sS[i-1] == "W":

            aE[i] = aE[i-1]+1

        else:

            aE[i] = aE[i-1]

    iMinCost = aE[iN-1]

    iW = 0 #西向かされる人

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

        if sS[i+1]=="E":

            iW += 1

        iMinCost = min(iMinCost,iW+aE[i])

    print(iMinCost)



解()

def 解():
    iN = int(eval(input()))
    sS = input().rstrip()
    aE = [0] * iN  # 東向かされる人
    aW = [0] * iN  # 西向かされる人
    for i in range(1, iN):
        if sS[i - 1] == "W":
            aE[i] = aE[i - 1] + 1
        else:
            aE[i] = aE[i - 1]
    iMinCost = aE[iN - 1]
    for i in range(iN - 2, -1, -1):
        if sS[i + 1] == "E":
            aW[i] = aW[i + 1] + 1
        else:
            aW[i] = aW[i + 1]
        iMinCost = min(iMinCost, aW[i] + aE[i])
    print(iMinCost)


解()

def 解():
    iN = int(eval(input()))
    sS = input().rstrip()
    aE = [0] * iN  # 東向かされる人
    for i in range(1, iN):
        if sS[i - 1] == "W":
            aE[i] = aE[i - 1] + 1
        else:
            aE[i] = aE[i - 1]
    iMinCost = aE[iN - 1]
    iW = 0  # 西向かされる人
    for i in range(iN - 2, -1, -1):
        if sS[i + 1] == "E":
            iW += 1
        iMinCost = min(iMinCost, iW + aE[i])
    print(iMinCost)


解()

-    aW = [0] * iN  # 西向かされる人 +    iW = 0  # 西向かされる人 -            aW[i] = aW[i + 1] + 1 -        else: -            aW[i] = aW[i + 1] -        iMinCost = min(iMinCost, aW[i] + aE[i]) +            iW += 1 +        iMinCost = min(iMinCost, iW + aE[i])