#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n;
	string s;
	cin >> n >> s;
	vector<int> sumE(n+1), sumW(n+1);
	sumE[0] = 0, sumW[0] = 0;

	for (int i = 1; i <= n; i++){
		sumE[i] = sumE[i-1];
		sumW[i] = sumW[i-1];
		if (s[i-1] == 'E'){
			sumE[i] += 1;
		}else{
			sumW[i] += 1;
		}
	}
	int ans = MOD;
	for (int i = 1; i <= n; i++){
		int temp1 = sumW[i-1];
		int temp2 = sumE[n] - sumE[i];
		ans = min(ans, temp1 + temp2);
	}

	cout << ans << endl;
	return 0;
}

#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define N 300005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define rev(a,n) reverse(a,a+n)
using namespace std;
int n,ans=300005,l[N],r[N];
char s[N];
int main() {
	cin>>n;
	rep1(i,1,n)cin>>s[i];
	rep1(i,2,n){
		l[i]=l[i-1]+(s[i-1]=='W');
	}
	ford(i,n-1,1){
		r[i]=r[i+1]+(s[i+1]=='E');
	}
	rep1(i,1,n){
		if(ans>l[i]+r[i]){
			ans=l[i]+r[i];
		} 
	}
	cout<<ans;
	return 0;
}
