KR,KB = list(map(int, input().split(' '))) S = input() position = [0 for _ in range(len(S))] p = 0 for i in range(len(S)): if S[i] == 'W': position[i] = 21 else: position[i] = p p = p + 1 length = 0 # check the removal patterns of 2**20 for i in range(1<<20): t = [] yes = True for j in range(len(S)): # remove the character at position[j] and check the condition if i & (1 << position[j]) == 0: t.append(S[j]) if S[j] == 'R' and KR < len(t) and t[len(t)-KR-1] == 'R': yes = False if S[j] == 'B' and KB < len(t) and t[len(t)-KB-1] == 'B': yes = False if yes: length = max(length, len(t)) print(length)