#include using namespace std; namespace { typedef double real; typedef long long ll; template ostream& operator<<(ostream& os, const vector& vs) { if (vs.empty()) return os << "[]"; auto i = vs.begin(); os << "[" << *i; for (++i; i != vs.end(); ++i) os << " " << *i; return os << "]"; } template istream& operator>>(istream& is, vector& vs) { for (auto it = vs.begin(); it != vs.end(); it++) is >> *it; return is; } int Kr, Kb; string S; void input() { cin >> Kr >> Kb; cin >> S; } bool check(const string& s) { int n = s.size(); for (int i = 0; i < n; i++) { if (s[i] == 'W') continue; int k = (s[i] == 'R' ? Kr : Kb); if (i - k >= 0 && s[i - k] == s[i]) return false; } return true; } map cache; int dfs(const string& s) { if (cache.count(s)) return cache[s]; //cout << s << endl; int n = s.size(); if (check(s)) return n; int ans = 0; for (int i = 0; i < n; i++) { if (s[i] == 'W') continue; ans = max(ans, dfs(s.substr(0, i) + s.substr(i + 1, n - i - 1))); } return cache[s] = ans; } void solve() { cout << dfs(S) << endl; } } int main() { input(); solve(); return 0; }