Kr,Kb = map(int,input().split()) S = input() ans = 0 for i in range(1<<20): lis = [] R,B = divmod(i,1<<10) r = 0 b = 0 for s in S: if s == "W": lis.append(s) if s == "R": if R >> r & 1: lis.append(s) r += 1 if s == "B": if B >> b & 1: lis.append(s) b += 1 ok = 1 for i,s in enumerate(lis): if s == "B" and i >= Kb and lis[i-Kb] == "B": ok = 0 if s == "R" and i >= Kr and lis[i-Kr] == "R": ok = 0 if ok: ans = max(ans,len(lis)) print(ans)