#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    char s[300005];
    int n;
    int minn = 99999999;
    cin >> n;
    cin >> s;

    for(int i = 0 ; i < n ; i ++)
    {
        int cnt = 0;
        for(int j = 0 ; j < i ; j ++)
        {
            if(s[j] == 'W')
            {
                cnt ++;
            }
        }
        for(int j = i + 1 ; j < n ; j ++)
        {
            if(s[j] == 'E')
            {
                cnt ++;
            }
        }

        if(cnt<minn)
            minn=cnt;
    }
    cout << minn << endl;
    return 0;
}
