#if 1

#include <bits/stdc++.h>
using namespace std;
int n,e,w,s = 1000000000,a[1000005];
char c[1000005];
int main()
{
    cin >> n;
	for(int i = 0;i < n;i++)
    {
        cin >> c[i];
        a[i] = w;
        w += (c[i] == 87);
    }
	for(int i = n-1;i >= 0;i--)
    {
        s = min(s,a[i]+e);
        e += (c[i] == 69);
    }
	cout<< s;
}

#endif // 1++