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, int l) { if (n == Length) { ans = Math.Max(ans, l); return; } if (S[n] == 'W') { Use[n] = true; DFS(n + 1, l + 1); } else { DFS(n + 1, l); int cnt = 0; Use[n] = true; if (S[n] == 'R') { for (int i = n - 1; i >= 0; i--) { if (Use[i]) cnt++; if (cnt == Kr && S[i] == 'R') { return; } } } else if (S[n] == 'B') { for (int i = n - 1; i >= 0; i--) { if (Use[i]) cnt++; if (cnt == Kb && S[i] == 'B') { return; } } } DFS(n + 1, l + 1); Use[n] = false; } } public void Solve() { Scan(); DFS(0, 0); Console.WriteLine(ans); } }