inpl = lambda: list(map(int,input().split()))

def get_sequence(arr):

    if len(arr) == 0:

        return [], []

    elements = []

    nums = []

    n = 1

    prev = arr[0]

    for c in arr[1:]:

        if c == prev:

            n += 1

        else:

            elements.append(prev)

            nums.append(n)

            prev = c

            n = 1

    elements.append(prev)

    nums.append(n)

    return elements, nums



N = int(eval(input()))

S = eval(input())

ele, num = get_sequence(S)

Estart = 1-int(ele[0]=='E')

NE = sum(num[Estart::2])

ans = cur = NE

for i in range(len(num)):

    if (i - Estart) % 2:

        cur += num[i]

    else:

        cur -= num[i]

        if cur < ans:

            ans = cur

print(ans)
inpl = lambda: list(map(int,input().split()))

N = int(eval(input()))

S = eval(input())

NE = S.count('E')

ans = cur = NE

for s in S:

    if s == 'E':

        cur -= 1

        if cur < ans:

            ans = cur

    else:

        cur += 1

print(ans)
inpl = lambda: list(map(int, input().split()))


def get_sequence(arr):
    if len(arr) == 0:
        return [], []
    elements = []
    nums = []
    n = 1
    prev = arr[0]
    for c in arr[1:]:
        if c == prev:
            n += 1
        else:
            elements.append(prev)
            nums.append(n)
            prev = c
            n = 1
    elements.append(prev)
    nums.append(n)
    return elements, nums


N = int(eval(input()))
S = eval(input())
ele, num = get_sequence(S)
Estart = 1 - int(ele[0] == "E")
NE = sum(num[Estart::2])
ans = cur = NE
for i in range(len(num)):
    if (i - Estart) % 2:
        cur += num[i]
    else:
        cur -= num[i]
        if cur < ans:
            ans = cur
print(ans)

inpl = lambda: list(map(int, input().split()))
N = int(eval(input()))
S = eval(input())
NE = S.count("E")
ans = cur = NE
for s in S:
    if s == "E":
        cur -= 1
        if cur < ans:
            ans = cur
    else:
        cur += 1
print(ans)

- - -def get_sequence(arr): -    if len(arr) == 0: -        return [], [] -    elements = [] -    nums = [] -    n = 1 -    prev = arr[0] -    for c in arr[1:]: -        if c == prev: -            n += 1 -        else: -            elements.append(prev) -            nums.append(n) -            prev = c -            n = 1 -    elements.append(prev) -    nums.append(n) -    return elements, nums - - -ele, num = get_sequence(S) -Estart = 1 - int(ele[0] == "E") -NE = sum(num[Estart::2]) +NE = S.count("E") -for i in range(len(num)): -    if (i - Estart) % 2: -        cur += num[i] -    else: -        cur -= num[i] +for s in S: +    if s == "E": +        cur -= 1 +    else: +        cur += 1