"use strict";

var main = function main(input) {
  var N = parseInt(input.split('\n')[0], 10);
  var S = input.split('\n')[1].split('');
  var init = 0;

  for (var i = 0; i < N; i++) {
    if (S[i] == 'E' && i != 0) {
      init++;
    }
  }

  var tmp = init;
  var min = init;

  for (var _i = 1; _i < N; _i++) {
    if (S[_i] == 'E' && S[_i - 1] == 'E') {
      tmp--;
    } else if (S[_i] == 'W' && S[_i - 1] == 'W') {
      tmp++;
    }

    if (tmp < min) {
      min = tmp;
    }
  }

  console.log(min);
};

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));