#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a) 
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a) 
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) { 
	return (1 + n) * n / 2;
}
//1から整数nまでの合計
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double sqrtNum = sqrt(a);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定

// ===============================================================

int main() {
	ll n;
	cin >> n;
	string a;
	cin >> a;
	vl x(n, 0);
	vl y(n, 0);
	for (int i = 0; i < n; i++) {
		if (a[i] == 'E') {
			if (i == 0) {
				x[i] = 1;
				y[i] = 0;
			}
			else {
				x[i] = x[i - 1] + 1;
				y[i] = y[i - 1];
			}
		}
		if (a[i] == 'W') {
			if (i == 0) {
				y[i] = 1;
				x[i] = 0;
			}
			else {
				y[i] = y[i - 1] + 1;
				x[i] = x[i - 1];
			}
		}
	}//x=E y=W
	ll count = 0;
	ll ans = 100000000;
	for (int i = 0; i < n; i++) {
		if (i != 0) {
			count = (x[n - 1] - x[i]) + y[i - 1];
		}
		else {
			count = x[n - 1] - x[i];
		}
		if (min(ans, count) == count) {
			ans = count;
		}
		count = 0;
	}
	cout << ans << endl;
}
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

int N; string S; vi l,r;
void input()
{
    cin>>N>>S;
}

void solve()
{
    int count=0;
    for(int i=0;i<N;++i) {
        if(S[i]=='W') ++count;
        l.emplace_back(count);
    }
    count=0;
    for(int i=0;i<N;++i) {
        if(S[N-1-i]=='E') ++count;
        r.emplace_back(count);
    }
    int MIN=100000000;
    for(int i=0;i<N;++i) {
        int tmp=0;
        if(i>0) tmp+=l[i-1];
        if(i<N-1) tmp+=r[N-2-i];
        MIN=min(MIN,tmp);
    }
    cout<<MIN<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}