import copy Kr,Kb = map(int,input().split()) S = list(input()) lsBR = [] for i in range(len(S)): if S[i] == 'B' or S[i] == 'R': lsBR.append(i) ans = 0 for i in range(2**len(lsBR)): S1 = copy.copy(S) for j in range(len(lsBR)): if (i>>j) & 1: S1[j] = '' S2 = ''.join(S1) f = True for j in range(len(S2)): if S2[j] == 'R': if j-Kr >= 0: if S2[j-Kr] == 'R': f = False break if j+Kr < len(S2): if S2[j+Kr] == 'R': f = False break elif S2[j] == 'B': if j-Kb >= 0: if S2[j-Kb] == 'B': f = False break if j+Kb < len(S2): if S2[j+Kb] == 'B': f = False break if f: ans = max(len(S2),ans) print(ans)