KR,KB = list(map(int, input().split(' '))) S = input() def meet(s): yes = True length = len(s) for i in range(len(s)): if s[i] == 'R': if (i+KR < length and s[i+KR] == 'R') or (0 <= i-KR and s[i-KR] == 'R'): yes = False elif s[i] == 'B': if (i+KB < length and s[i+KB] == 'R') or (0 <= i-KB and s[i-KB] == 'B'): yes = False return yes def solve(m,s): if meet(s): return len(s) for i in range(len(s)): if s[i] == 'R' or s[i] == 'B': return max(m, solve(m, s[:i] + s[i+1:])) print(solve(-1,S))