#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<numeric>
#include<functional>
#include<complex>

using namespace std;
#define BET(a,b,c) ((a)<=(b)&&(b)<(c))
#define FOR(i,n) for(int i=0,i##_end=(int(n));i<i##_end;i++)
#define SZ(x) (int)(x.size())
#define ALL(x) (x).begin(),(x).end()
#define MP make_pair
#define FOR_EACH(it,v) for(__typeof(v.begin()) it=v.begin(),it_end=v.end() ; it != it_end ; it++)
typedef vector<int> VI;
typedef vector<VI> VVI;

int main()
{
    int Kr,Kb;
    string s;
    cin>>Kr>>Kb>>s;
    VI r, b;
    FOR(i,SZ(s)) {
        if(s[i] == 'R') r.push_back(i);
        if(s[i] == 'B') b.push_back(i);
    }
    int ans = 0;
    FOR(i,1<<10) FOR(j,1<<10){
        VI removed(30);
        FOR(k,10) {
            if((1<<k) & i) removed[r[k]] = true;
            if((1<<k) & j) removed[b[k]] = true;
        }
        string t;
        FOR(k,30) if(!removed[k]) t += s[k];
        if(SZ(t) <= ans) continue;
        bool ok = true;
        FOR(k,SZ(t)) {
            if(k + Kr < SZ(t) && t[k] == 'R' && t[k + Kr] == 'R'){
                ok = false; break;
            }
            if(k + Kb < SZ(t) && t[k] == 'B' && t[k + Kb] == 'B'){
                ok = false; break;
            }
        }
        if(ok) ans = SZ(t);
    }
    cout<<ans<<endl;
    return 0;
}