# coding:UTF-8 import sys from itertools import combinations MOD = 10 ** 9 + 7 INF = float('inf') # 前処理なし def comb(n, k): if n < k: return 0 elif n < 0 or k < 0: return 0 a = 1 for i in range(k): a = a * (n - i) b = 1 for i in range(1, k+1): b = b * i return a // b Kr, Kb = list(map(int, input().split())) # スペース区切り連続数字 S = input() # 文字列 BRs = [] for i in range(30): if S[i] != "W": BRs.append(i) for i in range(21): possible_i = False Nt = 30 - i for r in combinations(BRs, i): nums = set(r) Stmp = [] for j in range(30): if j not in nums: Stmp.append(S[j]) possible = True for j in range(Nt): if Stmp[j] == "W": continue elif Stmp[j] == "R": if j - Kr >= 0: if Stmp[j - Kr] == "R": possible = False break if j + Kr <= Nt - 1: if Stmp[j + Kr] == "R": possible = False break elif Stmp[j] == "B": if j - Kb >= 0: if Stmp[j - Kb] == "B": possible = False break if j + Kb <= Nt - 1: if Stmp[j + Kb] == "B": possible = False break if possible: possible_i = True break if possible_i: res = Nt break print("{}".format(res))