Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[1:])["E"]]
th = Counter(st[:n])["W"]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
    if(th-(n-i) > min(ma)):
        break
print(min(ma))

Fixed submission:
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
print(sorted(ma)[0])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
th = Counter(st[:n])["W"] + Counter(st[n+1:])["E"]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
    if(th-(n-i) > min(ma)):
        break
print(min(ma))

Fixed submission:
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
print(sorted(ma)[0])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
th = Counter(st[:n])["W"] + Counter(st[n+1:])["E"]
previous = st[0]
for i in range(1,n):
    temp = ma[::-1][0]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
    if(th-(n-i) > min(ma)):
        break
print(min(ma))

Fixed submission:
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
print(sorted(ma)[0])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
th = Counter(st[:n])["W"] + Counter(st[n+1:])["E"]
previous = st[0]
for i in range(1,n):
    temp = ma[::-1][0]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
    if(th-(n-1) > min(ma)):
        break
print(min(ma))

Fixed submission:
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
print(sorted(ma)[0])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[::-1][0]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
    if(temp - (n-i) > min(ma)):
        break
print(min(ma))

Fixed submission:
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
print(sorted(ma)[0])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[::-1][0]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
print(min(ma))

Fixed submission:
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
print(sorted(ma)[0])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
if(stc["W"] == stc["E"] -1 or stc["W"] == stc["E"] +1 or stc["W"] == stc["E"]):
    for i in range(n):
        east = Counter(st[:i])["W"]
        west = Counter(st[i + 1:])["E"]
        l.append(east + west)
else:
    t = stc.most_common(1)[0][0]
    for i in range(n):
        if(st[i] == t):
            east = Counter(st[:i])["W"]
            west = Counter(st[i + 1:])["E"]
            l.append(east + west)
print(min(l))

Fixed submission:
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
print(sorted(ma)[0])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
st = input()
l = []
for i in range(n):
    temp = st[i]
    east = [0 if i == "E" else 1 for i in st[:i]]
    west = [0 if i == "W" else 1 for i in st[i+1:]]
    l.append(sum(east) + sum(west))
print(min(l))

Fixed submission:
from collections import Counter
n = int(input())
st = input()
l = []
stc = Counter(st)
ma = [Counter(st[:0])["W"] + Counter(st[1:])["E"]]
previous = st[0]
for i in range(1,n):
    temp = ma[-1]
    if(previous == "W"):
        temp+=1
    previous = st[i]
    if(st[i] == "E"):
        temp-=1
    ma.append(temp)
print(sorted(ma)[0])