n=int(eval(input()))

s=eval(input())

e=[int("E"==i) for i in s]

for i in range(1,n):

  e[i]+=e[i-1]



  

ans=[]

for j in range(n):

  left=j-0

  right=n-j-1

  

# leftにWは何個？

# leftのEは、

  if j-1>=0:

    etmp=e[j-1]

  else:

    etmp=0

  leftw=left-etmp

# rightにEは何個？

# rightのEは、

  eee=e[n-1]-e[j]

  ans+=(leftw+eee),

print((min(ans)))

"""

#include <iostream>

#include <cmath>

#include <vector>

#include <algorithm>

#include <iomanip>

int main()

{

    long N;

    std::cin >> N;

    std::string S;

    std::cin >> S;

    long count=0;

    std::vector<long> counters;

    for(long i=1; i<N; i++){

        if(S[i]=='E'){

            count++;

        }

    }

    counters.push_back(count);

    for(long i=1; i<N; i++){

        if(S[i]=='E'){

            count-=1;

        }

        if(S[i-1]=='W'){

            count++;

        }

        counters.push_back(count);

    }

    std::sort(counters.begin(),counters.end());

    std::cout << counters[0] << std::endl;

    return 0;

}

"""

n=int(eval(input()))

s=eval(input())

cnt=0

for i in range(1,n):

  if s[i]=="E":cnt+=1

ans=[]

ans.append(cnt)

for i in range(1,n):

  if s[i]=="E":

    cnt-=1

  if s[i-1]=="W":

    cnt+=1

  ans.append(cnt)

print((min(ans)))

n = int(eval(input()))
s = eval(input())
e = [int("E" == i) for i in s]
for i in range(1, n):
    e[i] += e[i - 1]
ans = []
for j in range(n):
    left = j - 0
    right = n - j - 1
    # leftにWは何個？
    # leftのEは、
    if j - 1 >= 0:
        etmp = e[j - 1]
    else:
        etmp = 0
    leftw = left - etmp
    # rightにEは何個？
    # rightのEは、
    eee = e[n - 1] - e[j]
    ans += ((leftw + eee),)
print((min(ans)))

"""
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
int main()
{
    long N;
    std::cin >> N;
    std::string S;
    std::cin >> S;
    long count=0;
    std::vector<long> counters;
    for(long i=1; i<N; i++){
        if(S[i]=='E'){
            count++;
        }
    }
    counters.push_back(count);
    for(long i=1; i<N; i++){
        if(S[i]=='E'){
            count-=1;
        }
        if(S[i-1]=='W'){
            count++;
        }
        counters.push_back(count);
    }
    std::sort(counters.begin(),counters.end());
    std::cout << counters[0] << std::endl;
    return 0;
}
"""
n = int(eval(input()))
s = eval(input())
cnt = 0
for i in range(1, n):
    if s[i] == "E":
        cnt += 1
ans = []
ans.append(cnt)
for i in range(1, n):
    if s[i] == "E":
        cnt -= 1
    if s[i - 1] == "W":
        cnt += 1
    ans.append(cnt)
print((min(ans)))

+""" +#include <iostream> +#include <cmath> +#include <vector> +#include <algorithm> +#include <iomanip> +int main() +{ +    long N; +    std::cin >> N; +    std::string S; +    std::cin >> S; +    long count=0; +    std::vector<long> counters; +    for(long i=1; i<N; i++){ +        if(S[i]=='E'){ +            count++; +        } +    } +    counters.push_back(count); +    for(long i=1; i<N; i++){ +        if(S[i]=='E'){ +            count-=1; +        } +        if(S[i-1]=='W'){ +            count++; +        } +        counters.push_back(count); +    } +    std::sort(counters.begin(),counters.end()); +    std::cout << counters[0] << std::endl; +    return 0; +} +""" -e = [int("E" == i) for i in s] +cnt = 0 -    e[i] += e[i - 1] +    if s[i] == "E": +        cnt += 1 -for j in range(n): -    left = j - 0 -    right = n - j - 1 -    # leftにWは何個？ -    # leftのEは、 -    if j - 1 >= 0: -        etmp = e[j - 1] -    else: -        etmp = 0 -    leftw = left - etmp -    # rightにEは何個？ -    # rightのEは、 -    eee = e[n - 1] - e[j] -    ans += ((leftw + eee),) +ans.append(cnt) +for i in range(1, n): +    if s[i] == "E": +        cnt -= 1 +    if s[i - 1] == "W": +        cnt += 1 +    ans.append(cnt)