using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; using System.IO; class Program { static void Main() { new Magatro().Solve(); } } class Magatro { private int Kr, Kb; private string S; private int ans = 0; private const int Length = 30; private bool[] Use = new bool[Length]; private void Scan() { var line = Console.ReadLine().Split(' '); Kr = int.Parse(line[0]); Kb = int.Parse(line[1]); S = Console.ReadLine(); } private void DFS(int n, string s) { if (n == Length) { for (int i = 0; i < s.Length; i++) { if (s[i] == 'R' && i - Kr >= 0) { if(s[i] == s[i - Kr]) { return; } } else if (s[i] == 'B' && i - Kb >= 0) { if(s[i] == s[i - Kb]) { return; } } } ans = Math.Max(ans, s.Length); return; } if (S[n] != 'W') { DFS(n + 1, s); } DFS(n + 1, s + S[n]); } public void Solve() { Scan(); DFS(0, ""); Console.WriteLine(ans); } }