import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int Kr = sc.nextInt(); final int Kb = sc.nextInt(); char[] inputs = sc.next().toCharArray(); int min = Integer.MAX_VALUE; for(int bit = 0; bit < (1 << 20); bit++){ final int reduced_size = inputs.length - Integer.bitCount(bit); char[] reduced_inputs = new char[reduced_size]; for(int normal = 0, reduced = 0, count = 0; normal < inputs.length; normal++){ if(inputs[normal] == 'W'){ reduced_inputs[reduced++] = inputs[normal]; continue; } final boolean is_ignored = (bit & (1 << (count++))) != 0; if(is_ignored){ continue; }else{ reduced_inputs[reduced++] = inputs[normal]; } } //System.out.println(Arrays.toString(reduced_inputs)); //sc.next(); boolean ok = true; for(int i = 0; i < reduced_size; i++){ if(reduced_inputs[i] == 'R' && ((i - Kr >= 0 && reduced_inputs[i - Kr] == 'R') || (i + Kr < reduced_size && reduced_inputs[i + Kr] == 'R'))){ ok = false; break; }else if(reduced_inputs[i] == 'B' && ((i - Kb >= 0 && reduced_inputs[i - Kb] == 'B') || (i + Kb < reduced_size && reduced_inputs[i + Kb] == 'B'))){ ok = false; break; } } if(ok){ min = Math.min(min, Integer.bitCount(bit)); } } System.out.println(inputs.length - min); } }