Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
count = count_E + count_W
ans = count + 1
for e in range S:
    if e == "E":
        count_E -= 1
    elif e == "W":
        count_W += 1
    if count < ans :
        ans = count
print(ans)

Fixed submission:
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
ans = count_E
for i in range(N):
    if S[i] == "E":
        count_E -= 1
    if S[i-1] == "W" and i != 0:
        count_W += 1
    if count_E + count_W < ans :
        ans = count_E + count_W
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
count = count_E + count_W
ans = count + 1
for e in range S:
    if e == "E":
        count_E -= 1
    elif e == "w":
        count_W += 1
    if count < ans :
        ans = count
print(ans)

Fixed submission:
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
ans = count_E
for i in range(N):
    if S[i] == "E":
        count_E -= 1
    if S[i-1] == "W" and i != 0:
        count_W += 1
    if count_E + count_W < ans :
        ans = count_E + count_W
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
count_list = []
camu_west = []
for i in range(1,N+1):
  look_west = len([S[j] for j in range(i) if S[j] == "W"])
  camu_west.append(look_west)
for i in range(N):
  count_l = camu_west[i-1]
  if i == 0:
    count_l = 0
  count_r = N-1-i-(camu_west[N-1]-camu_west[i])
  if i == N:
    count_r = 0
  count = count_l + count_r 
  count_list.append(count)
print(min(count_list))

Fixed submission:
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
ans = count_E
for i in range(N):
    if S[i] == "E":
        count_E -= 1
    if S[i-1] == "W" and i != 0:
        count_W += 1
    if count_E + count_W < ans :
        ans = count_E + count_W
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
count_list = []
camu_west = []
for i in range(1,N+1):
  look_west = len([S[j] for j in range(i) if S[j] == "W"])
  camu_west.append(look_west)
for i in range(N):
  count_l = camu_west[i-1]
  if i == 0:
    count_l = 0
  count_r = N-1-i-(camu_west[N-1]-camu_west[i])
  if i == N:
    count_r = 0
  count = count_l + count_r 
  count_list.append(count)
print(min(count_list))

Fixed submission:
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
ans = count_E
for i in range(N):
    if S[i] == "E":
        count_E -= 1
    if S[i-1] == "W" and i != 0:
        count_W += 1
    if count_E + count_W < ans :
        ans = count_E + count_W
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
count_list = []
for i in range(N):
  S_l = S[:i]
  S_r = S[i+1:]
  count = S_l.count("W") + S_r.count("E")
  count_list.append(count)
print(min(count_list))

Fixed submission:
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
ans = count_E
for i in range(N):
    if S[i] == "E":
        count_E -= 1
    if S[i-1] == "W" and i != 0:
        count_W += 1
    if count_E + count_W < ans :
        ans = count_E + count_W
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
count_list = []
for i in range(N):
  S_l = S[:i]
  S_r = S[i+1:]
  count = S_l.count("W") + S_r.count("E")
  count_list.append(count)
print(min(count_list))

Fixed submission:
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
ans = count_E
for i in range(N):
    if S[i] == "E":
        count_E -= 1
    if S[i-1] == "W" and i != 0:
        count_W += 1
    if count_E + count_W < ans :
        ans = count_E + count_W
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
count_list = []
for i in range(N):
  count1 = len([S[j] for j in range(N) if j < i and S[j] == "W" ])
  count2 = len([S[i] for j in range(N) if i < j and S[j] == "E"])
  count = count1 + count2
  count_list.append(count)
print(min(count_list))

Fixed submission:
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
ans = count_E
for i in range(N):
    if S[i] == "E":
        count_E -= 1
    if S[i-1] == "W" and i != 0:
        count_W += 1
    if count_E + count_W < ans :
        ans = count_E + count_W
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
count_list = []
for i in range(N):
  count1 = len([S[j] for j in range(N) if j < i and S[j] == "W" ])
  count2 = len([S[i] for j in range(N) if i < j and S[j] == "E"])
  count = count1 + count2
  count_list.append(count)
print(min(count_list))

Fixed submission:
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
ans = count_E
for i in range(N):
    if S[i] == "E":
        count_E -= 1
    if S[i-1] == "W" and i != 0:
        count_W += 1
    if count_E + count_W < ans :
        ans = count_E + count_W
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
count_list = []
for i in range(N):
  count = 0
  for j in range(N):
#   leader = i
    if j < i and S[j] == "W":
      count += 1
    elif i < j and S[j] == "E":
      count += 1
  count_list.append(count)
print(min(count_list))

Fixed submission:
N = int(input())
S = list(input())
count_E = S.count("E")
count_W = 0
ans = count_E
for i in range(N):
    if S[i] == "E":
        count_E -= 1
    if S[i-1] == "W" and i != 0:
        count_W += 1
    if count_E + count_W < ans :
        ans = count_E + count_W
print(ans)