nums = int(eval(input()))

direct = list(eval(input()))

ary_w = [0 for i in range(nums)]

ary_e = [0 for i in range(nums)]

count_w = 0

count_e = 0

count = 0

result = 100000000



for i in range(nums):

    if direct[i] == "W":

        count_w += 1

    elif direct[i] == "E":

        count_e += 1



    ary_w[i] = count_w

    ary_e[i] = count_e



for i in range(nums):

    w = ary_w[i-1]

    e = ary_e[-1] - ary_e[i]

    if i == 0:

        w = 0

        e = ary_e[-1]

    count = w+e

    if count < result:

        result = count

print(result)
n = int(eval(input()))

s = eval(input())

dp = [0]*n

dp[0] = s[1:].count("E")

a = s[0]

for i in range(1,n):

    dp[i] = dp[i-1]

    if s[i] == "E":dp[i] -= 1

    if a == "W":dp[i] += 1

    a = s[i]

print((min(dp)))
nums = int(eval(input()))
direct = list(eval(input()))
ary_w = [0 for i in range(nums)]
ary_e = [0 for i in range(nums)]
count_w = 0
count_e = 0
count = 0
result = 100000000
for i in range(nums):
    if direct[i] == "W":
        count_w += 1
    elif direct[i] == "E":
        count_e += 1
    ary_w[i] = count_w
    ary_e[i] = count_e
for i in range(nums):
    w = ary_w[i - 1]
    e = ary_e[-1] - ary_e[i]
    if i == 0:
        w = 0
        e = ary_e[-1]
    count = w + e
    if count < result:
        result = count
print(result)

n = int(eval(input()))
s = eval(input())
dp = [0] * n
dp[0] = s[1:].count("E")
a = s[0]
for i in range(1, n):
    dp[i] = dp[i - 1]
    if s[i] == "E":
        dp[i] -= 1
    if a == "W":
        dp[i] += 1
    a = s[i]
print((min(dp)))

-nums = int(eval(input())) -direct = list(eval(input())) -ary_w = [0 for i in range(nums)] -ary_e = [0 for i in range(nums)] -count_w = 0 -count_e = 0 -count = 0 -result = 100000000 -for i in range(nums): -    if direct[i] == "W": -        count_w += 1 -    elif direct[i] == "E": -        count_e += 1 -    ary_w[i] = count_w -    ary_e[i] = count_e -for i in range(nums): -    w = ary_w[i - 1] -    e = ary_e[-1] - ary_e[i] -    if i == 0: -        w = 0 -        e = ary_e[-1] -    count = w + e -    if count < result: -        result = count -print(result) +n = int(eval(input())) +s = eval(input()) +dp = [0] * n +dp[0] = s[1:].count("E") +a = s[0] +for i in range(1, n): +    dp[i] = dp[i - 1] +    if s[i] == "E": +        dp[i] -= 1 +    if a == "W": +        dp[i] += 1 +    a = s[i] +print((min(dp)))