#include<bits/stdc++.h>
using namespace std;

int main(){
	int n,ans=1e9;
	string s;
  	cin >> n >> s;
  	int a[300010];
  	a[0] = 0;
  
  	for (int i=0;i<n;i++){
      	cin >> s[i];
    	if(s[i]=='W') a[i+1]=a[i]+1;
      	else a[i+1]=a[i];
    }
  
  	for (int i=0;i<n;i++){
      
      	int k=a[i]+(n-i-1-(a[n]-a[i+1]));
      	ans=min(k,ans); 
    }
  	cout << ans <<endl;
}
