#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<t.size()){ if(t[i]==t[l])is = false; } if(r>=0&&r<=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(); }