#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int ret = 0, f = 1;
  while (ch > '9' || ch < '0') {
    if (ch == '0') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
  return ret * f;
}
const int mx = 1000005;
const long long mod = 1e9 + 7;
int n, k, X[mx], B[mx];
char s[mx];
long long S[mx], F[2][mx], D[mx];
void cr(int v, char c) {
  memset(X, 0, sizeof(X)), memset(B, 0, sizeof(B));
  for (int i = 1; i <= n; i++) {
    X[i] = X[i - 1], B[i] = B[i - 1];
    if (s[i - 1] == 'X') X[i]++;
    if (s[i - 1] != 'X' && s[i - 1] != c) B[i]++;
  }
  long long mn1 = 0ll, mn2 = 0ll;
  for (int i = k; i <= n; i++) {
    if (B[i] == B[i - k])
      F[v][i] = (D[X[i - k]] - mn1 - mn2 + 10ll * mod) % mod;
    if (s[i - k] == 'X') mn1 *= 2ll;
    mn1 += F[v][i - k + 1], mn1 %= mod;
    mn2 += mod - F[v][i - k + 1], mn2 += F[v][i], mn2 %= mod;
  }
}
int main() {
  long long res = 0;
  n = read(), k = read();
  D[0] = 1ll;
  for (int i = 1; i <= 1000001; i++) D[i] = (D[i - 1] * 2ll) % mod;
  scanf("%s", s);
  cr(0, 'B');
  reverse(s, s + n), cr(1, 'W');
  for (int i = 1; i <= n; i++) {
    S[i] = S[i - 1];
    if (s[i - 1] == 'X') S[i] *= 2ll;
    S[i] += F[1][i], S[i] %= mod;
  }
  for (int i = 1; i <= n; i++) res += S[i] * F[0][n - i], res %= mod;
  printf("%lld\n", res);
  return 0;
}
