#include using namespace std; int R, B; bool f(string s) { int n = s.size(); for (int i = 0; i < n; i++) { if (s.at(i) == 'R') { if (i - R >= 0) if (s.at(i - R) == 'R') return false; if (i + R < n) if (s.at(i + R) == 'R') return false; } if (s.at(i) == 'B') { if (i - B >= 0) if (s.at(i - B) == 'B') return false; if (i + B < n) if (s.at(i + B) == 'B') return false; } } return true; } int main() { string S; cin >> R >> B >> S; int ans = 0; for (int bit = 0; bit < 1 << 20; bit++) { string tmp; int cnt = 0; for (auto c : S) { if (c == 'W') { tmp += 'W'; continue; } if (bit >> cnt & 1) { tmp += c; } cnt++; } if (f(tmp)) ans = max(ans, (int) tmp.size()); } cout << ans << "\n"; }