_, s = open(0).read().split()

left, right = [0], []

lw, re = 0, 0

for i in s:

  if i == 'W':

    lw += 1

  left += [lw]

for i in s[::-1]:

  if i == 'E':

    re += 1

  right += [re]

print((min(i + j for i, j in zip(left[:-1], right[-2::-1] + [0]))))
def main():

  _, s = open(0).read().split()

  w, res = 0, 0

  for i in s:

    if i == 'W':

      w += 1

    elif w:

      w -= 1

      res += 1

    else:

      pass

  return res





if __name__ == '__main__':

  print((main()))
_, s = open(0).read().split()
left, right = [0], []
lw, re = 0, 0
for i in s:
    if i == "W":
        lw += 1
    left += [lw]
for i in s[::-1]:
    if i == "E":
        re += 1
    right += [re]
print((min(i + j for i, j in zip(left[:-1], right[-2::-1] + [0]))))

def main():
    _, s = open(0).read().split()
    w, res = 0, 0
    for i in s:
        if i == "W":
            w += 1
        elif w:
            w -= 1
            res += 1
        else:
            pass
    return res


if __name__ == "__main__":
    print((main()))

-_, s = open(0).read().split() -left, right = [0], [] -lw, re = 0, 0 -for i in s: -    if i == "W": -        lw += 1 -    left += [lw] -for i in s[::-1]: -    if i == "E": -        re += 1 -    right += [re] -print((min(i + j for i, j in zip(left[:-1], right[-2::-1] + [0])))) +def main(): +    _, s = open(0).read().split() +    w, res = 0, 0 +    for i in s: +        if i == "W": +            w += 1 +        elif w: +            w -= 1 +            res += 1 +        else: +            pass +    return res + + +if __name__ == "__main__": +    print((main()))