console.log((args=>{
  const [_N,S] = args.trim().split`\n`;
  const N = _N|0;
  const w = Array(N).fill(0), e = Array(N).fill(0);
  for ( let i = 1; i < N; i++ ) {
    w[i] = w[i-1] + (S[i-1]==='W');
    e[N-i-1] = e[N-i] + (S[N-i]==='E');
  }
  let min = N;
  for ( let i = 0; i < N; i++ ) {
    const v = w[i] + e[i];
    if ( min > v ) min = v;
  }
  return min;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));
