'use strict'

function Main(input) {
  const N = Number(input.split('\n')[0]);
  const S = input.split('\n')[1].split('');

  let S_left, S_right;
  let change = 0;
  let changelist = [];

  for(let i=0; i<N; i++){
    S_left = S.slice(0,i);
    S_right = S.slice(i+1);

    for(let j=0; j<S_left.length; j++){
      if(S_left[j] === 'W'){
        change++;
      }
    }
    for(let k=0; k<S_right.length; k++){
      if(S_right[k] === 'E'){
        change++;
      }
    }
    changelist.push(change);
    change = 0;
  }
    
    console.log(Math.min.apply(null, changelist));
}

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