N = int(input())
C=list(input())
W=(C.count('W'))
R=N-W
WW=0
RR=0
X=[0]*(N-1)
if W>0 and R>0:
  for i in range(N-1):
    if C[i]=='W':
      WW+=1
    RR=(N-i-1)-(W-WW)
    X[i]=max(WW,RR)
print(min(X)) N = int(input()) N int(input()) int input() input C=list(input()) C list(input()) list input() input W=(C.count('W')) W C.count('W') C.count C count 'W' R=N-W R N-W N W WW=0 WW 0 RR=0 RR 0 X=[0]*(N-1) X [0]*(N-1) [0] 0 N-1 N 1 if W>0 and R>0:
  for i in range(N-1):
    if C[i]=='W':
      WW+=1
    RR=(N-i-1)-(W-WW)
    X[i]=max(WW,RR) W>0 and R>0 W>0 W 0 R>0 R 0 for i in range(N-1):
    if C[i]=='W':
      WW+=1
    RR=(N-i-1)-(W-WW)
    X[i]=max(WW,RR) i range(N-1) range N-1 N 1 if C[i]=='W':
      WW+=1
     C[i]=='W' C[i] C i 'W' WW+=1 WW 1 RR=(N-i-1)-(W-WW) RR (N-i-1)-(W-WW) N-i-1 N-i N i 1 W-WW W WW X[i]=max(WW,RR) X[i] X i max(WW,RR) max WW RR print(min(X)) print min(X) min X N = int(input()) int(input()) N RR=(N-i-1)-(W-WW) (N-i-1)-(W-WW) RR WW=0 0 WW R=N-W N-W R RR=0 0 RR C=list(input()) list(input()) C X=[0]*(N-1) [0]*(N-1) X W=(C.count('W')) C.count('W') W WW+=1 1 WW
N = int(input())
C=list(input())
W=(C.count('W'))
R=N-W
WW=0
RR=0
X=[0]*(N-1)
if W>0 and R>0:
  for i in range(N-1):
    if C[i]=='W':
      WW+=1
    RR=(N-i-1)-(W-WW)
    X[i]=max(WW,RR)
print(min(X))