'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 changemin = 0;

  for(let i=0; i<N; i++){
    if(S[i+1] === 'E'){
      change++;
    }
  }
  changemin = change;

  for(let j=1; j<N; j++){
    if(S[j-1] === 'W'){
      change++;
    }
    if(S[j] === 'E'){
      change--;
    }
    if(changemin > change) {
      changemin = change;
    }
  }

/*
  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(changemin);
}

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