#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <functional>
#include <iostream>


using namespace std;
 
//namaega184 
 
int main(){
	 
	int r,b;char s[101];scanf("%d%d%s",&r,&b,s); 
	set<string> st;st.insert(string(s));
	auto cmparetor=[](string &a,string &b){return a.size()<b.size();};
	priority_queue<string,vector<string>,decltype(cmparetor)> pq(cmparetor);pq.push(string(s));
	int change=1;
	int ans=0;
	auto ischange=[&](string str,int pos,int npos){
		str.erase(str.begin()+pos+npos);
		//printf("%s\n",str.c_str());
		if(st.find(str)==st.end()){ 
			pq.push(str);st.insert(str);
		}
		return 1;
	};
	while(change){
		change = 0;
		string tmp;
		for(int i=0;i<pq.size();i++){
			tmp=pq.top();pq.pop(); 
			change=0;
			for(int j=0;j<tmp.size();j++){
				if(tmp[j]=='R'){
					if(j+r<tmp.size()&&tmp[j+r]=='R')change|=ischange(tmp,j,r);
					if(j-r>=0&&tmp[j-r]=='R')change|=ischange(tmp,j,-r);
					 
				}
				else if(tmp[j]=='B'){
					if(j+b<tmp.size()&&tmp[j+b]=='B')change|=ischange(tmp,j,b);
					if(j-b>=0&&tmp[j-b]=='B')change|=ischange(tmp,j,-b);
				}
			}
			if(change==0)break;
		}
		ans=tmp.size();
	}
	printf("%d\n",ans);  
	return 0; 
}