#include <bits/stdc++.h>
using namespace std;
int n, k, b[1100000], w[1100000];
long long f[1100000], g[1100000], ans = 0, c[1100000], x[1100000];
char str[1100000];
long long mo(long long a) {
  if (a >= 0 && a < 1000000007) return a;
  a %= 1000000007;
  if (a < 0) a += 1000000007;
  return a;
}
int main() {
  scanf("%d%d", &n, &k);
  c[0] = 1;
  for (int i = 1; i <= n; i++) c[i] = mo(c[i - 1] * 2);
  scanf("%s", str + 1);
  for (int i = 1; i <= n; i++) {
    b[i] = b[i - 1];
    w[i] = w[i - 1];
    x[i] = x[i - 1];
    if (str[i] == 'B') b[i]++;
    if (str[i] == 'W') w[i]++;
    if (str[i] == 'X') x[i]++;
  }
  for (int i = n - k + 1; i; i--) {
    f[i] = f[i + 1];
    if (str[i] == 'X') f[i] = mo(f[i] * 2);
    if ((i == n - k + 1 || str[i + k] != 'W') &&
        (b[i + k - 1] - b[i - 1] == 0)) {
      if (i == n - k + 1)
        f[i] = 1;
      else
        f[i] = mo(f[i] + c[x[n] - x[i + k]] - f[i + k + 1]);
    }
  }
  for (int i = k; i <= n; i++) {
    g[i] = g[i - 1];
    if (str[i] == 'X') g[i] = mo(g[i] * 2);
    long long tot = g[i];
    if ((i == k || str[i - k] != 'B') && (w[i] - w[i - k] == 0)) {
      if (i == k)
        g[i] = 1;
      else
        g[i] = mo(g[i] + c[x[i - k - 1]] - g[i - k - 1]);
    }
    ans = mo(ans + mo(g[i] - tot) * f[i + 1]);
  }
  cout << ans << endl;
  return 0;
}
