#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000010;
const int MO = 1000000007;
char S[MAXN];
int blen[2][MAXN];
int sum[MAXN][3][2];
int n, k;
int len;
int ch(char c) {
  if (c == 'X') return 2;
  return c == 'B' ? 0 : 1;
}
void pre() {
  int cur[2] = {0};
  for (int i = 0; i < len; ++i) {
    for (int l = 0; l < 2; ++l) {
      if (ch(S[i]) == (l ^ 1))
        cur[l] = 0;
      else
        ++cur[l];
      blen[l][i + 1] = cur[l];
    }
  }
}
int cal_sum(int x, int y, int l, int r) {
  if (l < 0 || r > l) return 0;
  if (r < 0) r = 0;
  if (r == 0) return sum[l][x][y];
  int tmp = ((long long)sum[l][x][y] - sum[r - 1][x][y]) % MO;
  tmp = ((long long)tmp + MO) % MO;
  return tmp;
}
void solve() {
  pre();
  memset(sum, 0, sizeof(sum));
  sum[0][0][0] = sum[0][0][1] = 1;
  int f[3][2];
  for (int i = 1; i <= len; ++i) {
    f[0][0] = cal_sum(0, 1, i - 1, max(i - blen[0][i], i - (k - 1)));
    f[0][1] = cal_sum(0, 0, i - 1, i - blen[1][i]);
    f[1][0] = cal_sum(0, 1, i - k, i - blen[0][i]) +
              cal_sum(1, 1, i - 1, i - blen[0][i]);
    f[1][1] = cal_sum(1, 0, i - 1, max(i - blen[1][i], i - (k - 1)));
    f[2][0] = cal_sum(2, 1, i - 1, i - blen[0][i]);
    f[2][1] = cal_sum(1, 0, i - k, i - blen[1][i]) +
              cal_sum(2, 0, i - 1, i - blen[1][i]);
    for (int l = 0; l < 3; ++l)
      for (int k = 0; k < 2; ++k)
        sum[i][l][k] = ((long long)f[l][k] + sum[i - 1][l][k]) % MO;
  }
  int res = ((long long)f[2][0] + f[2][1]) % MO;
  printf("%d\n", res);
}
int main() {
  scanf("%d%d%s", &n, &k, S);
  len = strlen(S);
  solve();
  return 0;
}
