#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

int gcd(int a, int b)
{
	if (a%b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a%b));
	}
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> wl(n);
	vector<int> el(n);
	string s;
	cin >> s;
	rep(i, n) {
		if (i - 1 >= 0) {
			wl[i] = wl[i - 1];
			el[i] = el[i - 1];
		}
		if (s[i] == 'W') {
			wl[i]++;
		}
		else{
			el[i]++;
		}
	}
	int ans = 1000000000;
	rep(i, n) {
		int ec = 0;
		int wc = 0;
		if (i - 1 > 0) {
			wc = wl[i - 1];
		}
		ec = el[el.size() - 1] - el[i];
		ans = min(ans, ec + wc);
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}


#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int east[n], west[n];
    rep(i, n) west[i] = 0;
    if (s[0] == 'W')
        west[0] = 1;
    else
        west[0] = 0;
    for (int i = 1; i < n; ++i)
    {
        if (s[i] == 'W')
            west[i] = west[i - 1] + 1;
        else
            west[i] = west[i - 1];
    }
    if (s[n - 1] == 'E')
        east[n - 1] = 1;
    else
        east[n - 1] = 0;
    for (int i = n - 2; i >= 0; --i)
    {
        if (s[i] == 'E')
            east[i] = east[i + 1] + 1;
        else
            east[i] = east[i + 1];
    }
    int cnt = n;
    rep(i, n)
    {
        if (east[i] + west[i] < cnt)
        {
            cnt = east[i] + west[i];
        }
    }
    cout << cnt - 1 << endl;
    return 0;
}