#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6;
char s[maxn + 1];
int dW[maxn + 1], dB[maxn + 1];
int cntW[maxn + 1], cntB[maxn + 1];
const int MOD = (int)1e9 + 7;
inline int mmod(int x) { return x >= MOD ? x - MOD : x < 0 ? x + MOD : x; }
int main() {
  int n, k;
  while (scanf("%d%d%s", &n, &k, s) >= 1) {
    dW[0] = 1;
    for (int i = 0, sum = dW[0], needkill = -1; i < n; i++) {
      dW[i + 1] = (s[i] == 'B') ? 0 : sum;
      if (i >= k - 1 && needkill <= i) sum -= dW[i - k + 1];
      if (s[i] == 'W') sum = 0, needkill = i + k;
      sum += dW[i + 1];
      sum = mmod(sum);
    }
    dB[n] = 1;
    for (int i = n - 1, sum = dB[n], needkill = n; i >= 0; i--) {
      dB[i] = (s[i] == 'W') ? 0 : sum;
      if (i + k <= n && needkill >= i) sum -= dB[i + k];
      if (s[i] == 'B') sum = 0, needkill = i - k;
      sum += dB[i];
      sum = mmod(sum);
    }
    cntW[0] = cntB[0] = 0;
    for (int i = 0; i < n; i++) {
      cntW[i + 1] = cntW[i] + (s[i] == 'W');
      cntB[i + 1] = cntB[i] + (s[i] == 'B');
    }
    int ans = 0;
    for (int l = n - 2 * k, countr = 0; l >= 0; l--) {
      if (s[l + k] == 'X') countr = mmod(2 * countr);
      if (cntB[l + 2 * k] - cntB[l + k] == 0)
        countr = mmod(countr + dB[l + 2 * k]);
      if (cntW[l + k] - cntW[l] == 0) {
        ans = (ans + (long long)dW[l] * countr) % MOD;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
