#include <bits/stdc++.h>
using namespace std;
const int mod = (int)1e9 + 7;
const int maxn = 3000000;
int n, k;
int fB[maxn], fW[maxn];
int sB[maxn], sW[maxn];
char second[maxn];
int main() {
  scanf("%d%d\n", &n, &k);
  for (int i = 1; i <= n; ++i) second[i] = getchar();
  for (int i = 1; i <= n; ++i) {
    sW[i] = sW[i - 1] + (second[i] == 'W');
    sB[i] = sB[i - 1] + (second[i] == 'B');
  }
  fB[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fB[i] = fB[i - 1];
    if (second[i] == 'X') fB[i] = (fB[i] * 2) % mod;
    if (i - k - 1 >= 0 && sW[i] - sW[i - k] == 0 && second[i - k] != 'B')
      fB[i] = (fB[i] - fB[i - k - 1] + mod) % mod;
    else if (i - k == 0 && sW[i] == 0)
      fB[i] = (fB[i] + mod - 1) % mod;
  }
  fW[n + 1] = 1;
  for (int i = n; i >= 1; --i) {
    fW[i] = fW[i + 1];
    if (second[i] == 'X') fW[i] = (fW[i] * 2) % mod;
    if (i + k + 1 <= n + 1 && sB[i + k - 1] - sB[i - 1] == 0 &&
        second[i + k] != 'W')
      fW[i] = (fW[i] - fW[i + k + 1] + mod) % mod;
    else if (i + k - 1 == n && sB[i + k - 1] - sB[i - 1] == 0)
      fW[i] = (fW[i] - 1 + mod) % mod;
  }
  long long ans = 0, cur = 0;
  for (int i = n - k; i >= 1; --i) {
    int j = i + k;
    if (j <= n && second[j] == 'X') cur = (cur + cur) % mod;
    if (j + k - 1 <= n && sB[j + k - 1] - sB[j - 1] == 0 &&
        second[j + k] != 'W') {
      int tmp = 1;
      if (j + k + 1 <= n + 1) tmp = (tmp * 1ll * fW[j + k + 1]) % mod;
      cur = (cur + tmp) % mod;
    }
    if (second[i - 1] != 'B' && sW[i + k - 1] - sW[i - 1] == 0) {
      int tmp = 1;
      if (i - 2 >= 0) tmp = fB[i - 2];
      tmp = (tmp * 1ll * cur) % mod;
      ans = (ans + tmp) % mod;
    }
  }
  cout << ans << endl;
  return 0;
}
