# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a

# C - Attention



# C_Attention.py



N = int(eval(input()))

S = eval(input())



e = [0 for i in range(N)]

w = [0 for i in range(N)]

d = [0 for i in range(N)]



# 累積和を求める

for i in range(N):

    # そこからE側の人で、Wを向くべきなのにEを向いている人

    if i > 0:

        w[i] += w[i-1]

    if i < N-1:

        if S[i] == "W":

            w[i+1] += 1

    # そこからW側の人で、Eを向くべきなのにWを向いている人

    if i > 0:

        e[N-1-i] += e[N-1-(i-1)]

    if i < N-1:

        if S[N-1-i] == "E":

            e[N-1-(i+1)] += 1



min = 10 ** 6

for i in range(N):

    total = e[i] + w[i]

    if total < min:

        min = total

print(min)

# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a

# C - Attention



# C_Attention_beta.py



N = int(eval(input()))

S = eval(input())



e = [0 for i in range(N)]

w = [0 for i in range(N)]

d = [0 for i in range(N)]



# 累積和を求める

for i in range(N):

    # そこからE側の人で、Wを向くべきなのにEを向いている人

    if i > 0:

        w[i] += w[i-1]

    if i < N-1:

        if S[i] == "W":

            w[i+1] += 1





# そこからW側の人で、Eを向くべきなのにWを向いている人

for j in range(N):

    i = N-1-j

    if i < N-1:

        e[i] += e[i+1]

    if i > 0:

        if S[i] == "E":

            e[i-1] += 1





min = 10 ** 6

for i in range(N):

    total = e[i] + w[i]

    if total < min:

        min = total

print(min)

# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention
# C_Attention.py
N = int(eval(input()))
S = eval(input())
e = [0 for i in range(N)]
w = [0 for i in range(N)]
d = [0 for i in range(N)]
# 累積和を求める
for i in range(N):
    # そこからE側の人で、Wを向くべきなのにEを向いている人
    if i > 0:
        w[i] += w[i - 1]
    if i < N - 1:
        if S[i] == "W":
            w[i + 1] += 1
    # そこからW側の人で、Eを向くべきなのにWを向いている人
    if i > 0:
        e[N - 1 - i] += e[N - 1 - (i - 1)]
    if i < N - 1:
        if S[N - 1 - i] == "E":
            e[N - 1 - (i + 1)] += 1
min = 10**6
for i in range(N):
    total = e[i] + w[i]
    if total < min:
        min = total
print(min)

# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention
# C_Attention_beta.py
N = int(eval(input()))
S = eval(input())
e = [0 for i in range(N)]
w = [0 for i in range(N)]
d = [0 for i in range(N)]
# 累積和を求める
for i in range(N):
    # そこからE側の人で、Wを向くべきなのにEを向いている人
    if i > 0:
        w[i] += w[i - 1]
    if i < N - 1:
        if S[i] == "W":
            w[i + 1] += 1
# そこからW側の人で、Eを向くべきなのにWを向いている人
for j in range(N):
    i = N - 1 - j
    if i < N - 1:
        e[i] += e[i + 1]
    if i > 0:
        if S[i] == "E":
            e[i - 1] += 1
min = 10**6
for i in range(N):
    total = e[i] + w[i]
    if total < min:
        min = total
print(min)

-# C_Attention.py +# C_Attention_beta.py -    # そこからW側の人で、Eを向くべきなのにWを向いている人 +# そこからW側の人で、Eを向くべきなのにWを向いている人 +for j in range(N): +    i = N - 1 - j +    if i < N - 1: +        e[i] += e[i + 1] -        e[N - 1 - i] += e[N - 1 - (i - 1)] -    if i < N - 1: -        if S[N - 1 - i] == "E": -            e[N - 1 - (i + 1)] += 1 +        if S[i] == "E": +            e[i - 1] += 1