import itertools def judge(s): for i in range(Kr,len(s)-Kr): if s[i] == s[i+Kr] == "R": return False if s[i] == s[i-Kr] == "R": return False for i in range(Kb,len(s)-Kb): if s[i] == s[i+Kb] == "B": return False if s[i] == s[i-Kb] == "B": return False return True Kr,Kb = map(int,raw_input().split()) S = list(raw_input()) r = [i for i in range(30) if S[i] == "R"] b = [i for i in range(30) if S[i] == "B"] ans = 0 for i in range(10): if 30-i <= ans: break for pull_r in itertools.combinations(r,i): for j in range(10): if 30-i-j <= ans: break for pull_b in itertools.combinations(b,j): s = [S[k] for k in range(30) if k not in pull_r+pull_b] if judge(s): ans = max(ans, len(s)) print ans