Buggy python submission (verdict: Time Limit Exceeded):
# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention

# C_Attention.py

N = int(input())
S = input()

#e = [0 for i in range(N)]
#w = [0 for i in range(N)]
d = [0 for i in range(N)]
#print("累積和")

for i in range(N):
    # そこからE側の人で、Wを向くべきなのにEを向いている人
    if S[i] == "E":
        for j in range(0, i):
            #e[j]+=1
            d[j]+=1
    # そこからW側の人で、Eを向くべきなのにWを向いている人
    else:
        for j in range(i+1, N):
            #w[j]+=1
            d[j]+=1
    #print("i:", i)
    #print("w:", w)
    #print("e:", e)
    #print("")

#w[0] = 0
#e[-1] = 0

#print("w:", w)
#print("e:", e)
min = 10 ** 6

for i in range(N):
    if d[i] < min:
        min = d[i]
print(min)


Fixed submission:
# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention

# C_Attention.py

N = int(input())
S = input()

e = [0 for i in range(N)]
w = [0 for i in range(N)]
d = [0 for i in range(N)]
#print("累積和")

for i in range(N):
    # そこからE側の人で、Wを向くべきなのにEを向いている人
    #if S[i] == "E":
    #    for j in range(0, i):
    #        e[j]+=1
    #        d[j]+=1
    # そこからW側の人で、Eを向くべきなのにWを向いている人
    if i > 0:
        w[i] += w[i-1]
    if i < N-1:
        if S[i] == "W":
            w[i+1] += 1
    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

    #print("i:", i)
    #print("w:", w)
    #print("e:", e)
    #print("")

#w[0] = 0
#e[-1] = 0

#print("w:", w)
#print("e:", e)
min = 10 ** 6
for i in range(N):
    total = e[i] + w[i]
    if total < min:
        min = total
print(min)

Buggy python submission (verdict: Time Limit Exceeded):
# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention

# C_Attention.py

N = int(input())
S = input()

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

#print("累積和")

for i in range(N):
    # そこからE側の人で、Wを向くべきなのにEを向いている人
    if S[i] == "E":
        for j in range(0, i):
            e[j]+=1
    # そこからW側の人で、Eを向くべきなのにWを向いている人
    elif S[i] == "W":
        for j in range(i+1, N):
            w[j]+=1
    #print("i:", i)
    #print("w:", w)
    #print("e:", e)
    #print("")

#w[0] = 0
#e[-1] = 0

#print("w:", w)
#print("e:", e)
min = 10 ** 6

for i in range(N):
    total = e[i]+w[i]
    if total < min:
        min = total
print(min)


Fixed submission:
# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention

# C_Attention.py

N = int(input())
S = input()

e = [0 for i in range(N)]
w = [0 for i in range(N)]
d = [0 for i in range(N)]
#print("累積和")

for i in range(N):
    # そこからE側の人で、Wを向くべきなのにEを向いている人
    #if S[i] == "E":
    #    for j in range(0, i):
    #        e[j]+=1
    #        d[j]+=1
    # そこからW側の人で、Eを向くべきなのにWを向いている人
    if i > 0:
        w[i] += w[i-1]
    if i < N-1:
        if S[i] == "W":
            w[i+1] += 1
    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

    #print("i:", i)
    #print("w:", w)
    #print("e:", e)
    #print("")

#w[0] = 0
#e[-1] = 0

#print("w:", w)
#print("e:", e)
min = 10 ** 6
for i in range(N):
    total = e[i] + w[i]
    if total < min:
        min = total
print(min)