r, b = map(int, input().split()) S = input() ans = 10 for bit in range(1 << 20): i = 0 use = [] for s in S: if s == "W": use.append(s) continue if (bit >> i) & 1: use.append(s) i += 1 ok = True for i, s in enumerate(use): if s == "R" and i + r < len(use) and use[i + r] == "R": ok = False break elif s == "B" and i + b < len(use) and use[i + b] == "B": ok = False break if ok and len(use) > ans: ans = len(use) print(ans)