#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int Kr, Kb; string S; int N; int dfs(int i, int idx, vector &str) { if (i >= N) { return idx; } int res = 0; if (S[i] == 'W') { str[idx] = 'W'; res = max(res, dfs(i + 1, idx + 1, str)); str[idx] = '#'; } else if (S[i] == 'R') { if (idx - Kr < 0 || (idx - Kr >= 0 && str[idx - Kr] != 'R')) { str[idx] = 'R'; res = max(res, dfs(i + 1, idx + 1, str)); str[idx] = '#'; } res = max(res, dfs(i + 1, idx, str)); } else { if (idx - Kb < 0 || (idx - Kb >= 0 && str[idx - Kb] != 'B')) { str[idx] = 'B'; res = max(res, dfs(i + 1, idx + 1, str)); str[idx] = '#'; } res = max(res, dfs(i + 1, idx, str)); } return res; } int main() { cin >> Kr >> Kb; cin >> S; N = S.size(); vector str(N); cout << dfs(0, 0, str) << endl; return 0; }