#include <bits/stdc++.h>
using namespace std;
string P;
int count_B;
int A,B;
int Bpos[5011];
int main() {
while (scanf("%d %d",&A,&B)!=EOF){
memset(Bpos,-1,sizeof(Bpos));
int idx=0;
count_B=0;
cin>> P;
for (int i=0;i<P.size();++i){
if (P[i]=='B'){
count_B++;
Bpos[idx]=i;
idx++;
}
}
string aux;
int minimo=0x3f3f3f3f;
for (int i=0;i<=count_B;++i){
int Arot=i;
int cata=idx-1;
int costo=0;
for (int j=0;j<count_B;++j){
if (P[j]=='B'){
if (Bpos[cata]==j)
cata--;
if (cata<0) break;
}
else{
if (Arot){
Arot--;
costo+=A;
cata--;
}else{
costo+=((A-B)*( abs(Bpos[cata]-j ) ));
cata--;
if (cata<0) break;
}
}
}
minimo=min(minimo, costo);
}
printf("%d\n",minimo);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RyaW5nIFA7CgppbnQgY291bnRfQjsKCmludCBBLEI7CgppbnQgQnBvc1s1MDExXTsKCmludCBtYWluKCkgewoJCgl3aGlsZSAoc2NhbmYoIiVkICVkIiwmQSwmQikhPUVPRil7CgkJCgkJbWVtc2V0KEJwb3MsLTEsc2l6ZW9mKEJwb3MpKTsKCQkKCQlpbnQgaWR4PTA7CgkJY291bnRfQj0wOwoJCWNpbj4+IFA7CgkJCgkJZm9yIChpbnQgaT0wO2k8UC5zaXplKCk7KytpKXsKCQkJaWYgKFBbaV09PSdCJyl7CgkJCQljb3VudF9CKys7CgkJCQlCcG9zW2lkeF09aTsKCQkJCWlkeCsrOwoJCQl9CgkJfQoJCXN0cmluZyBhdXg7CgkJaW50IG1pbmltbz0weDNmM2YzZjNmOwoJCWZvciAoaW50IGk9MDtpPD1jb3VudF9COysraSl7CgkJCWludCBBcm90PWk7CgkJCgkJCWludCBjYXRhPWlkeC0xOwoJCQkKCQkJaW50IGNvc3RvPTA7CgkJCQoJCQlmb3IgKGludCBqPTA7ajxjb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