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

int main(){
  int N;
  string S;
  cin >> N >> S;
  vector<int> W(N,0);
  for(int i=0;i<N;i++){
    if(i==0 && S.at(i)=='W') W.at(i) = 1;
    else if(i==0 && S.at(i)=='E') W.at(i) = 0;
    else if(S.at(i)=='W') W.at(i) = W.at(i-1) +1;
    else W.at(i) = W.at(i-1);
  }
  int p_min = 0;
  for(int i=0;i<N;i++){
    if(i==0) p_min = N - 1 - W.at(N-1) + W.at(i);
    else if(p_min > W.at(i-1) + ( N - (i+1) ) - ( W.at(N-1) - W.at(i) ) ){
      p_min = W.at(i-1) + ( N - (i+1) ) - ( W.at(N-1) - W.at(i) );
    }
  }
  cout << p_min << endl;
}
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


int main(){
  int n,k; cin >> n >> k;
  cout << n-k+1 << endl;
}
