from itertools import*;eval(input());s=eval(input());print((min(w+e for w,e in zip(*[([0]+list(accumulate(list(map(int,s[::a].translate(str.maketrans("EW","01"[::a]))))))[:-1])[::a]for a in[-1,1]]))))
eval(input());s=eval(input());m=c=s.count("E")

for t in s:c-=t<"W";m=min(m,c);c+=t>"E"

print(m)

from itertools import *

eval(input())
s = eval(input())
print(
    (
        min(
            w + e
            for w, e in zip(
                *[
                    (
                        [0]
                        + list(
                            accumulate(
                                list(
                                    map(
                                        int,
                                        s[::a].translate(
                                            str.maketrans("EW", "01"[::a])
                                        ),
                                    )
                                )
                            )
                        )[:-1]
                    )[::a]
                    for a in [-1, 1]
                ]
            )
        )
    )
)

eval(input())
s = eval(input())
m = c = s.count("E")
for t in s:
    c -= t < "W"
    m = min(m, c)
    c += t > "E"
print(m)

-from itertools import * - -print( -    ( -        min( -            w + e -            for w, e in zip( -                *[ -                    ( -                        [0] -                        + list( -                            accumulate( -                                list( -                                    map( -                                        int, -                                        s[::a].translate( -                                            str.maketrans("EW", "01"[::a]) -                                        ), -                                    ) -                                ) -                            ) -                        )[:-1] -                    )[::a] -                    for a in [-1, 1] -                ] -            ) -        ) -    ) -) +m = c = s.count("E") +for t in s: +    c -= t < "W" +    m = min(m, c) +    c += t > "E" +print(m)