import std.stdio;
import std.string;
import std.array;
import std.range;
import std.algorithm;
import std.conv;

void main(string[] args) {
  readln();
  string input = readln().chomp;

  int cur = 0;
  int min = 0;
  int e = 0;

  foreach(c; input){
    if(c == 'E'){e++; cur--;}
    else{cur++;}
    if(cur < min){min = cur;}
  }

  writeln(min+e);
}