#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int Kr, Kb;
string S;
int N;

int dfs(int i, int idx, vector<char> &str) {
  if (i >= N) {
    return idx;
  }

  int res = 0;

  if (S[i] == 'W') {
    str[idx] = 'W';
    res = max(res, dfs(i + 1, idx + 1, str));
    str[idx] = '#';
  } else if (S[i] == 'R') {
    if (idx - Kr < 0 || (idx - Kr >= 0 && str[idx - Kr] != 'R')) {
      str[idx] = 'R';
      res = max(res, dfs(i + 1, idx + 1, str));
      str[idx] = '#';
    }

    res = max(res, dfs(i + 1, idx, str));
  } else {
    if (idx - Kb < 0 || (idx - Kb >= 0 && str[idx - Kb] != 'B')) {
      str[idx] = 'B';
      res = max(res, dfs(i + 1, idx + 1, str));
      str[idx] = '#';
    }

    res = max(res, dfs(i + 1, idx, str));
  }

  return res;
}

int main() {
  cin >> Kr >> Kb;
  cin >> S;
  N = S.size();
  vector<char> str(N);

  cout << dfs(0, 0, str) << endl;

  return 0;
}