import itertools R, B = map(int, input().split()) S = input() ans = 0 for t in itertools.product((0, 1), repeat=20): j = 0 S_new = [] for s in S: if s == 'W': S_new.append(s) else: if t[j]: S_new.append(s) j += 1 l = len(S_new) for j in range(l): if S_new[j] == 'R': if (j - R >= 0 and S_new[j - R] == 'R') or (j + R < l and S_new[j + R] == 'R'): break elif S_new[j] == 'B': if (j - B >= 0 and S_new[j - B] == 'B') or (j + B < l and S_new[j + B] == 'B'): break else: ans = max(ans, l) print(ans)