Buggy python submission (verdict: Time Limit Exceeded):
N = input()                                                                                         
# c = list(map(int, input().split()))                                                               
c = input()                                                                                         
                                                                                                    
N = int(N)                                                                                          
                                                                                                    
dp = []                                                                                             
                                                                                                    
n_w = c.count('W')                                                                                  
n_r = c.count('R')                                                                                  
                                                                                                    
for i in range(N + 1):                                                                                  
    left_w = c[:i].count('W')                                                                       
    right_r = n_r - (i - left_w)                                                                         
    dp.append(max(left_w, right_r))                                                                 
                                                                                                    
print(min(dp))                                                                                      

Fixed submission:
N = input()                                                                                         
c = input()                                                                                         
                                                                                                    
N = int(N)                                                                                          
                                                                                                    
n_r = c.count('R')                                                                                  
print(c[n_r:].count('R'))

Buggy python submission (verdict: Time Limit Exceeded):
N = input()                                                                                         
c = input()

N = int(N)                                                                                          
                                                                                                    
dp = []                                                                                             
                                                                                                    
for i in range(N + 1):                                                                                  
    dp.append(max(c[:i].count('W'), c[i:].count('R')))                                              
                                                                                                    
print(min(dp))


Fixed submission:
N = input()                                                                                         
c = input()                                                                                         
                                                                                                    
N = int(N)                                                                                          
                                                                                                    
n_r = c.count('R')                                                                                  
print(c[n_r:].count('R'))