'use strict';
function Main(stdin){
  const input = stdin.trim().split(/\r?\n/g);
  const N = Number(input[0]);
  const S = input[1].split('');
  let min_count = N;
  for(let i = 0; i < N; i++){
      let count = 0;
      for(let j = 0; j < N; j++){
          if(j < i){
              if(S[j] === 'W') count++;
          } else if (i < j){
              if(S[j] === 'E') count++;
          }
          if(min_count < count) break;
      }
      if(count < min_count) min_count = count;
  }
  console.log(min_count);
}

// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));