#include using namespace std; #define REP(i, n) for(ll i = 0; i < (ll)(n); i++) #define FOR(i,n,m) for (ll i=n; i < (ll)(m); i++) #define INF 1000000007 #define pb push_back #define MAX_N 200 #define MAX_T 10010 typedef long long ll; int Kr,Kb; string S; ll gcd(ll a, ll b){ if(b == 0) return a; return gcd(b, a%b); } ll lcm(ll a, ll b){ return a * b / gcd(a,b); } bool chk(string &s){ REP(i,s.length()){ if(s[i]=='R'){ if(i+Kr=0 && s[i-Kr]=='R') return false; } if(s[i]=='B'){ if(i+Kb=0 && s[i-Kb]=='B') return false; } } return true; } string int2bit(int n){ string ret=""; REP(i,20){ if(n>>i & 1) ret+="1"; else ret+="0"; } return ret; } int main(){ cin >> Kr >> Kb >> S; int rcnt=0,bcnt=0; int b[10],a[10]; REP(i,30){ if(S[i]=='R'){ a[rcnt]=i; rcnt++; } if(S[i]=='B'){ b[bcnt]=i; bcnt++; } } int ans=0; REP(mask,1<<21){ int use[30]; REP(i,30){ if(S[i]=='W') use[i]=1; else use[i]=0; } REP(i,10){ if(mask>>i & 1) use[a[i]]=1; } REP(i,10){ if(mask>>(i+10) & 1) use[b[i]]=1; } string ts=""; REP(i,30){ if(use[i]) ts+=S[i]; } if(chk(ts)) ans=max(ans,(int)ts.length());//cout<