#include<bits/stdc++.h>
//#include<atcoder/all>
// Begin Header {{{
//using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
template<class T, class S> inline bool chmax(T &a, const S &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T, class S> inline bool chmin(T &a, const S &b) { if (a>b) { a = b; return 1; } return 0; }
#define INT(...)                                                                                                                                               \
    int __VA_ARGS__;                                                                                                                                           \
    IN(__VA_ARGS__)
#define LL(...)                                                                                                                                                \
    ll __VA_ARGS__;                                                                                                                                            \
    IN(__VA_ARGS__)
#define STR(...)                                                                                                                                               \
    string __VA_ARGS__;                                                                                                                                        \
    IN(__VA_ARGS__)
#define CHR(...)                                                                                                                                               \
    char __VA_ARGS__;                                                                                                                                          \
    IN(__VA_ARGS__)
#define DBL(...)                                                                                                                                               \
    double __VA_ARGS__;                                                                                                                                        \
    IN(__VA_ARGS__)
template<class T> void scan(T &a) { cin >> a; }
void IN() {}
template<class Head, class... Tail> void IN(Head &head, Tail &... tail){ scan(head); IN(tail...); }
// }}} End Header



int main() {
	LL(n);
	STR(s);
	ll west_cnt = 0;
	ll east_cnt = 0;

	loop(i, 1, n) if(s[i] == 'E') east_cnt++;
	ll min = east_cnt;
	loop(i, 1, n){
		if(s[i-1] == 'W') west_cnt++;
		if(s[i] == 'E') east_cnt--;
		chmin(min, west_cnt+east_cnt);
	}
	cout << min << endl;
	return 0;
}

#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  int n,ans,W[310000] = {},E[310000] = {};
  string s;
  cin >> n >> s;
  
  for(int i = 1; i <= n-1; i++) {
    if(s[i-1] == 'W') 
      W[i] = W[i-1] + 1;
    else W[i] = W[i-1];
  }
  for(int i = n-2; i >= 0; i--) {
    if(s[i+1] == 'E') 
      E[i] = E[i+1] + 1;
    else E[i] = E[i+1];
  }

  int m = n;
  for(int i = 0; i < n; i++)
    m = min(m,W[i]+E[i]);
  
  cout << m << endl;
}