Buggy python submission (verdict: Runtime Error):
N = input()
S = list(input())

length = len(S)
min_num = 300000
left = 0
right = S.count("E")

for i in range(length):

  if i > 0:
    left += int(S[i - 1] == "W")

  if i < length:
    right -= int(S[i + 1] == "E")

  if left + right < min_num:
    min_num = left + right

print(min_num)


Fixed submission:
N = input()
S = list(input())

length = len(S)
min_num = 300000
left = 0
right = S.count("E")

for i in range(length):

  if i > 0:
    left += int(S[i - 1] == "W")

  if i < length:
    right -= int(S[i] == "E")

  if left + right < min_num:
    min_num = left + right

print(min_num)

Buggy python submission (verdict: Runtime Error):
N = input()
S = list(input())

min_num = 300000
left = 0
right = S.count("E")

for i in range(len(S)):

  if i > 0:
    left += int(S[i - 1] == "W")

  right -= int(S[i + 1] == "E")

  if left + right < min_num:
    min_num = left + right

print(min_num)


Fixed submission:
N = input()
S = list(input())

length = len(S)
min_num = 300000
left = 0
right = S.count("E")

for i in range(length):

  if i > 0:
    left += int(S[i - 1] == "W")

  if i < length:
    right -= int(S[i] == "E")

  if left + right < min_num:
    min_num = left + right

print(min_num)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
S = list(input())

min_num = 300000
left = 0

for i in range(len(S)):

  if i > 0:
    left += int(S[i - 1] == "W")

  right = S[i+1: ].count("E")

  if left + right < min_num:
    min_num = left + right

print(min_num)


Fixed submission:
N = input()
S = list(input())

length = len(S)
min_num = 300000
left = 0
right = S.count("E")

for i in range(length):

  if i > 0:
    left += int(S[i - 1] == "W")

  if i < length:
    right -= int(S[i] == "E")

  if left + right < min_num:
    min_num = left + right

print(min_num)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
S = list(input())

min_num = 300000

for i in range(len(S)):

  left = S[: i].count("W")
  right = S[i+1: ].count("E")

  if left + right < min_num:
    min_num = left + right

print(min_num)


Fixed submission:
N = input()
S = list(input())

length = len(S)
min_num = 300000
left = 0
right = S.count("E")

for i in range(length):

  if i > 0:
    left += int(S[i - 1] == "W")

  if i < length:
    right -= int(S[i] == "E")

  if left + right < min_num:
    min_num = left + right

print(min_num)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
S = list(input())

turns_num_list = list()

for i in range(len(S)):

  left = S[: i].count("W")
  right = S[i+1: ].count("E")

  turns_num_list.append(left+right)

print(min(turns_num_list))


Fixed submission:
N = input()
S = list(input())

length = len(S)
min_num = 300000
left = 0
right = S.count("E")

for i in range(length):

  if i > 0:
    left += int(S[i - 1] == "W")

  if i < length:
    right -= int(S[i] == "E")

  if left + right < min_num:
    min_num = left + right

print(min_num)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
S = list(input())

turns_num_list = list()

for i in range(len(S)):

  left = [s == "W" for s in S[: i]].count(True)
  right = [s == "E" for s in S[i+1: ]].count(True)

  turns_num_list.append(left+right)

print(min(turns_num_list))

Fixed submission:
N = input()
S = list(input())

length = len(S)
min_num = 300000
left = 0
right = S.count("E")

for i in range(length):

  if i > 0:
    left += int(S[i - 1] == "W")

  if i < length:
    right -= int(S[i] == "E")

  if left + right < min_num:
    min_num = left + right

print(min_num)

Buggy python submission (verdict: Runtime Error):
N = input()
S = split(input())

turns_num_list = list()
for i, s in enumerate(S):
  left = [S == "E" for j in S[0:j]].count()
  right = [S[j] == "W" for j in S[j+1:]].count()
  turns_num_list.append(left+right)

print(min(turns_num_list))

Fixed submission:
N = input()
S = list(input())

length = len(S)
min_num = 300000
left = 0
right = S.count("E")

for i in range(length):

  if i > 0:
    left += int(S[i - 1] == "W")

  if i < length:
    right -= int(S[i] == "E")

  if left + right < min_num:
    min_num = left + right

print(min_num)