import java.util.Scanner; public class Yuki038 { public static void main(String[] args) { Yuki038 hoge = new Yuki038(); } Yuki038() { Scanner scanner = new Scanner(System.in); int kr = scanner.nextInt(); int kb = scanner.nextInt(); String s = scanner.next(); int ans = 0; int N = s.length(); int mask = 0; for (int i = 0; i < N; i++) { if (s.charAt(i) == 'W') { mask |= 1 << i; } } for (int i = mask; i < (1 << N); i = (i + 1) | mask) { String t = ""; for (int j = 0; j < N; j++) { if (s.charAt(j) == 'W' || (((1 << j) & i) > 0)) { t += s.charAt(j); } } boolean hit = false; for (int j = 0; j < t.length(); j++) { if (t.charAt(j) == 'W') { continue; } for (int[] c : new int[][]{{'R', kr}, {'B', kb}}) { if (s.charAt(j) == c[0]) { if (j >= c[1]) { hit |= t.charAt(j - c[1]) == c[0]; } if (j + c[1] < t.length()) { hit |= t.charAt(j + c[1]) == c[0]; } } } if (hit) { break; } } if (!hit) { ans = Math.max(ans, t.length()); } } System.out.println(ans); } }