import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int kr = sc.nextInt(); int kb = sc.nextInt(); char[] inputs = sc.next().toCharArray(); int[] idxes = new int[inputs.length]; int counter = 0; for (int i = 0; i < inputs.length; i++) { if (inputs[i] == 'W') { idxes[i] = -1; } else { idxes[i] = counter++; } } int ans = 0; char[] tmp = new char[inputs.length]; for (int i = 0; i < (1 << counter); i++) { int k = 0; boolean enable = true; for (int j = 0; j < inputs.length; j++) { if (idxes[j] == -1) { tmp[k++] = 'W'; } else { if ((i & (1 << idxes[j])) == 0) { continue; } if (inputs[j] == 'R') { if (k - kr >= 0 && tmp[k - kr] == 'R') { enable = false; break; } tmp[k++] = 'R'; } else { if (k - kb >= 0 && tmp[k - kb] == 'B') { enable = false; break; } tmp[k++] = 'B'; } } } if (enable) { ans = Math.max(ans, k); } } System.out.println(ans); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }