import java.util.Scanner; public class Main_yukicoder38 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int kr = sc.nextInt(); int kb = sc.nextInt(); char[] s = sc.next().toCharArray(); int max = 0; for (int mask = 0; mask < 0x1 << 20; mask++) { int ir = 0; int ib = 0; StringBuilder tmp = new StringBuilder(); for (int i = 0; i < s.length; i++) { if (s[i] == 'R') { if ((mask & 0x1 << ir++) != 0) { continue; } } else if (s[i] == 'B') { if ((mask & 0x1 << 10 + ib++) != 0) { continue; } } tmp.append(s[i]); } if (isOK(tmp, kr, kb)) { max = Math.max(max, 30 - Integer.bitCount(mask)); } } System.out.println(max); sc.close(); } private static boolean isOK(StringBuilder s, int kr, int kb) { int n = s.length(); for (int i = 0; i < n; i++) { if (s.charAt(i) == 'R') { if (i - kr >= 0 && s.charAt(i - kr) == 'R') { return false; } if (i + kr < n && s.charAt(i + kr) == 'R') { return false; } } else if (s.charAt(i) == 'B') { if (i - kb >= 0 && s.charAt(i - kb) == 'B') { return false; } if (i + kb < n && s.charAt(i + kb) == 'B') { return false; } } } return true; } }