from itertools import combinations 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 def rec(s): global ans if s in used: return used.add(s) if len(s) <= ans: return if judge(s): ans = len(s) return for i in range(len(s)): if s[i] == "W": continue rec(s[:i]+s[i+1:]) Kr,Kb = map(int,raw_input().split()) S = raw_input() used = set([]) ans = 12 rec(S) print ans