#include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; using ll = long long; int r,b; string s; void solve(){ int ans =0; for(int bit = 0;bit<(1<<20);bit++){ string t; int j = 0; for(int i =0;i<30;i++){ if(s[i]=='W'){ t.push_back('W'); }else{ if((bit>>j)&1){ t.push_back(s[i]); } j++; } } bool is = true; for(int i =0;i<t.size();i++){ if(t[i]=='W')continue; int L = i - (t[i]=='R'?r:b),R = i + (t[i]=='R'?r:b); if(L>=0&&L<(int)t.size()){ if(t[i]==t[L])is = false; } if(R>=0&&R<(int)t.size()){ if(t[i]==t[R])is = false; } } if(is)ans = max(ans,(int)t.size()); } cout<<ans<<endl; } signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cin >> r >> b; cin >> s; solve(); }