#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
const int maxn = 1000010;
int f[maxn], g[maxn];
int sw[maxn], sb[maxn], sx[maxn];
int p[maxn];
const int mod = 1000000007;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  string s;
  cin >> s;
  s = "#" + s;
  for (int i = 1; i <= n; ++i) {
    sw[i] += sw[i - 1], sb[i] += sb[i - 1], sx[i] += sx[i - 1];
    switch (s[i]) {
      case 'X':
        sx[i]++;
        break;
      case 'W':
        sw[i]++;
        break;
      case 'B':
        sb[i]++;
        break;
    }
  }
  f[0] = 1;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == 'X')
      f[i] = f[i - 1] * 2LL % mod;
    else
      f[i] = f[i - 1];
    if (i - k >= 0 && sw[i] - sw[i - k] == 0) {
      int pr = 1;
      if (i - k) pr = f[i - k - 1];
      if (s[i - k] != 'B') f[i] = (mod + f[i] - pr) % mod;
    }
  }
  g[n + 1] = 1;
  for (int i = n; i >= 1; --i) {
    if (s[i] == 'X')
      g[i] = g[i + 1] * 2LL % mod;
    else
      g[i] = g[i + 1];
    if (i + k <= n + 1 && sb[i + k - 1] - sb[i - 1] == 0) {
      int pr = 1;
      if (i + k + 1 <= n + 1) pr = g[i + k + 1];
      if (s[i + k] != 'W') g[i] = (mod + g[i] - pr) % mod;
    }
  }
  p[0] = 1;
  for (int i = 1; i < maxn; ++i) p[i] = p[i - 1] * 2LL % mod;
  int ans = 0;
  for (int i = k; i <= n; ++i) {
    if (sw[i] - sw[i - k] == 0) {
      int pr = 1;
      if (i - k - 1 != -1) pr = f[i - k - 1];
      if (s[i - k] != 'B')
        ans =
            (ans + (long long)pr *
                       (long long)((p[sx[n] - sx[i]] + mod - g[i + 1]) % mod)) %
            mod;
    }
  }
  printf("%d\n", ans);
  return 0;
}
