#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
using  P=pair<ll,ll>;
int main(){
  ll counte=0,countw=0;
  string str;
  cin>>str>>str;
  vector<ll> w((ll)str.size());
  vector<ll> e((ll)str.size());
  for(ll i=0;i<(ll)str.size();i++){
    if(i==0){
      if(str.at(i)=='E'){e.at(i)=1;w.at(i)=0;counte++;}
      else{e.at(i)=0;w.at(i)=1;countw++;}
    }
    else{
      if(str.at(i)=='E'){e.at(i)=e.at(i-1)+1;w.at(i)=w.at(i-1);counte++;}
      else{e.at(i)=e.at(i-1);w.at(i)=w.at(i-1)+1;countw++;}
    }
  }
  ll ans;
  for(ll i=0;i<(ll)str.size();i++){
    if(i==0){ans=counte-e.at(0);}
    else if(i==(ll)str.size()-1){ans=min(ans,w.at(i));}
    else{ans=min(ans,w.at(i-1)+counte-e.at(i));}
  }
  cout<<ans<<endl;
}
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, l;
    cin >> n >> l;
    
    int sum = 0;
    int best = 1e8;
    rep (i, n) {
        int x = l + i;
        sum += x;
        if (abs(best) > abs(x)) {
            best = x;
        }
    }

    sum -= best;
    println(sum)

    return 0;
}