#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>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

void f()
{
  int a,b;
  cin>>a>>b;
  cout<<max(a+b,max(2*a-1,2*b-1))<<nl;
}

int main()
{
    su;
    f();
    return 0;
}
