Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import numpy as np
n=int(input())
c=input()
d=Counter(c)
wn,rn=Counter(c)["W"], Counter(c)["R"]

MIN=min(wn,rn)
ans=np.full(n+1,200001)

for i in range(MIN):
  w=Counter(c[:i])["W"]
  r=rn-(i-w)
  if w<=r:
    ans[i]=r
  else:
    ans[i]=w
    
l=[i for i in range(n) if ans[i]!=200001]

if l:
  print(np.min(ans))
else:
  print(0)


Fixed submission:
from collections import Counter
n=int(input())
c=input()
d=Counter(c)
w,r=Counter(c)["W"], Counter(c)["R"]
ans=0
for i in range(r):
  if c[i]=="W":
    ans+=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
c=input()
d=Counter(c)
wn,rn=Counter(c)["W"], Counter(c)["R"]

MIN=min(wn,rn)
ans=[]

for i in range(MIN):
  w=Counter(c[:i])["W"]
  r=rn-(i-w)
  if w<=r:
    ans.append(r)
  else:
    ans.append(w)

if ans:
  print(min(ans))
else:
  print(0)

Fixed submission:
from collections import Counter
n=int(input())
c=input()
d=Counter(c)
w,r=Counter(c)["W"], Counter(c)["R"]
ans=0
for i in range(r):
  if c[i]=="W":
    ans+=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
c=input()
d=Counter(c)
MIN=min(Counter(c)["W"],Counter(c)["R"])
ans=[]

for i in range(MIN):
  w=Counter(c[:i])["W"]
  r=Counter(c[i:])["R"]
  if w<=r:
    ans.append(r)
  else:
    ans.append(w)

if ans:
  print(min(ans))
else:
  print(0)

Fixed submission:
from collections import Counter
n=int(input())
c=input()
d=Counter(c)
w,r=Counter(c)["W"], Counter(c)["R"]
ans=0
for i in range(r):
  if c[i]=="W":
    ans+=1

print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
c=input()
d=Counter(c)
MIN=min(Counter(c)["W"],Counter(c)["R"])
ans=[]
for i in range(MIN):
  if Counter(c[:i])["W"]<=Counter(c[i:])["R"]:
    ans.append(Counter(c[i:])["R"])
  else:
    ans.append(Counter(c[i:])["W"])
    
print(min(ans))

Fixed submission:
from collections import Counter
n=int(input())
c=input()
d=Counter(c)
w,r=Counter(c)["W"], Counter(c)["R"]
ans=0
for i in range(r):
  if c[i]=="W":
    ans+=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import copy 
n=int(input())
c=input()
cl=copy.deepcopy(c)
cl=list(cl)
d=Counter(c)
ans=0


if d["R"]==0 or d["W"]==0:
  print(0)
  exit()
swap=0
if d["R"]>=n//2:
  r=n//2
else:
  r=d["R"]
  
for i in range(r):
  indexes = [j for j, x in enumerate(cl) if x == "R"]
  #print(cl)
  if cl[i]=="W":
    cl[indexes[-1]]="W"
    cl[i]="R"
    swap+=1

#print(cl)
#print(cl[cl.index("W"):])
#print(swap)
d=Counter(cl[cl.index("W"):])
ans+=swap+d["R"]
print(ans)


Fixed submission:
from collections import Counter
n=int(input())
c=input()
d=Counter(c)
w,r=Counter(c)["W"], Counter(c)["R"]
ans=0
for i in range(r):
  if c[i]=="W":
    ans+=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import copy 
n=int(input())
c=input()
cl=copy.deepcopy(c)
cl=list(cl)
d=Counter(c)
ans=0


if d["R"]==0 or d["W"]==0:
  print(0)
  exit()
swap=0
for i in range(n//2):
  indexes = [j for j, x in enumerate(cl) if x == "R"]
  #print(cl)
  if cl[i]=="W":
    cl[indexes[-1]]="W"
    cl[i]="R"
    swap+=1

#print(cl)
#print(cl[cl.index("W"):])

d=Counter(cl[cl.index("W"):])
ans+=swap+d["R"]
print(ans)

Fixed submission:
from collections import Counter
n=int(input())
c=input()
d=Counter(c)
w,r=Counter(c)["W"], Counter(c)["R"]
ans=0
for i in range(r):
  if c[i]=="W":
    ans+=1

print(ans)