import sys

kr, kb=map(int, input().split())
s = input()
idx = [i for i, c in enumerate(s) if c!='W']
import itertools
for l in range(20):
    for myon in itertools.combinations(idx, l):
        t = [c for i, c in enumerate(s) if i not in myon]
        judge = True
        for j, c in enumerate(t):
            if c == 'R' and j + kr < len(t) and t[j+kr] == 'R':
                judge = False
                break
            elif c == 'B' and j + kb < len(t) and t[j+kb] == 'B':
                judge = False
                break
        if judge:
            print(30-l)
            exit()