#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  init();
  ll N;
  cin >> N;
  string S;
  cin >> S;
  ll count_W = 0;
  ll count_E = 0;

  rep(i, S.size()) {
    if (S[i] == 'W') {
      count_W++;
    } else {
      count_E++;
    }
  }

  ll t_W = 0;
  ll t_E = 0;
  ll mini = INF;
  rep(i, S.size()) {
    if (S[i] == 'W') {
      ll count = t_W + count_E - (t_E + 0);
      if (count < mini) {
        mini = count;
      }
    } else {
      ll count = t_W + count_E - (t_E + 1);
      if (count < mini) {
        mini = count;
      }
    }

    if (S[i] == 'W') {
      t_W++;
    } else {
      t_E++;
    }
  }
  COUT(mini);
  return 0;
}
// C Attention
#include <bits/stdc++.h>
using namespace std;

vector<int> input(int N){
    vector<int> vec;    
    int temp = 0;
    for (int i = 0; i < N; i++ )    {
        cin >> temp;
        vec.push_back(temp);
    }
    return vec;
}


int main(){
    int N; // 100
    cin >> N;
    string str;
    cin >> str;
    vector<int> east_num(N);
    vector<int> west_num(N);

    if (str.at(0)=='E'){
        east_num.at(0) = 1;
        west_num.at(0) = 0;
    }else{
        east_num.at(0) = 0;
        west_num.at(0) = 1;
    }
    for (int i =0; i <N-1; i++)    {
        if(str.at(i+1) == 'E'){
            east_num.at(i+1) = east_num.at(i)+1;
            west_num.at(i+1) = west_num.at(i);            
        }
        else{
            east_num.at(i+1) = east_num.at(i);
            west_num.at(i+1) = west_num.at(i)+1;            
        }
    }
    int min_val = east_num.at(N-1) - east_num.at(0);
    for (int i =0; i <N-1; i++)    {
        int value = east_num.at(N-1) - east_num.at(i+1) + west_num.at(i);
        if (value < min_val) min_val = value;
    }    
  /*
   for (int i =0; i <N; i++)    {
      cout << east_num.at(i) << " ";
    }
      cout << endl;
  for (int i =0; i <N; i++)    {
      cout << west_num.at(i) << " ";
    }
      cout << endl;
   */  
    cout << min_val << endl;
}