N = int(input())
S = input()
w = 0
r = 0
for s in S:
    if s == "W":
        w += 1
    else:
        r += 1

res = r
rcnt = [0 for i in range(N+1)]
wcnt = [0 for i in range(N+1)]

for i in range(N):
    if S[i] == "W":
        wcnt[i+1] = wcnt[i] + 1
        rcnt[i+1] = r
    else:
        r -= 1
        rcnt[i+1] = r
        wcnt[i+1] = wcnt[i]
    res = min(res, max(wcnt[i+1], rcnt[i+1]))
print(res) N = int(input()) N int(input()) int input() input S = input() S input() input w = 0 w 0 r = 0 r 0 for s in S:
    if s == "W":
        w += 1
    else:
        r += 1 s S if s == "W":
        w += 1
    else:
        r += 1 s == "W" s "W" w += 1 w 1 r += 1 r 1 res = r res r 0 for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) 0 rcnt = [0 for i in range(N+1)] rcnt [0 for i in range(N+1)] 0 for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) 0 wcnt = [0 for i in range(N+1)] wcnt [0 for i in range(N+1)] for i in range(N):
    if S[i] == "W":
        wcnt[i+1] = wcnt[i] + 1
        rcnt[i+1] = r
    else:
        r -= 1
        rcnt[i+1] = r
        wcnt[i+1] = wcnt[i]
    res = min(res, max(wcnt[i+1], rcnt[i+1])) i range(N) range N if S[i] == "W":
        wcnt[i+1] = wcnt[i] + 1
        rcnt[i+1] = r
    else:
        r -= 1
        rcnt[i+1] = r
        wcnt[i+1] = wcnt[i]
     S[i] == "W" S[i] S i "W" wcnt[i+1] = wcnt[i] + 1 wcnt[i+1] wcnt i+1 i 1 wcnt[i] + 1 wcnt[i] wcnt i 1 rcnt[i+1] = r rcnt[i+1] rcnt i+1 i 1 r r -= 1 r 1 rcnt[i+1] = r rcnt[i+1] rcnt i+1 i 1 r wcnt[i+1] = wcnt[i] wcnt[i+1] wcnt i+1 i 1 wcnt[i] wcnt i res = min(res, max(wcnt[i+1], rcnt[i+1])) res min(res, max(wcnt[i+1], rcnt[i+1])) min res max(wcnt[i+1], rcnt[i+1]) max wcnt[i+1] wcnt i+1 i 1 rcnt[i+1] rcnt i+1 i 1 print(res) print res w = 0 0 w res = r r res wcnt = [0 for i in range(N+1)] [0 for i in range(N+1)] wcnt r += 1 1 r rcnt = [0 for i in range(N+1)] [0 for i in range(N+1)] rcnt w += 1 1 w r = 0 0 r res = min(res, max(wcnt[i+1], rcnt[i+1])) min(res, max(wcnt[i+1], rcnt[i+1])) res N = int(input()) int(input()) N S = input() input() S r -= 1 1 r
N = int(input())
S = input()
w = 0
r = 0
for s in S:
    if s == "W":
        w += 1
    else:
        r += 1

res = r
rcnt = [0 for i in range(N+1)]
wcnt = [0 for i in range(N+1)]

for i in range(N):
    if S[i] == "W":
        wcnt[i+1] = wcnt[i] + 1
        rcnt[i+1] = r
    else:
        r -= 1
        rcnt[i+1] = r
        wcnt[i+1] = wcnt[i]
    res = min(res, max(wcnt[i+1], rcnt[i+1]))
print(res)