#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
const int MOD = 1000000007;
void read(int &k) {
  k = 0;
  char x = getchar();
  while (x < '0' || x > '9') x = getchar();
  while (x >= '0' && x <= '9') {
    k = k * 10 - 48 + x;
    x = getchar();
  }
}
void update(int &a, long long b) { a = (a + b) % MOD; }
int n, k, sx[N], sb[N], sw[N], dp[N][3], tmp, tra[N][3];
char s[N];
int main() {
  scanf("%d%d%s", &n, &k, s + 1);
  for (int i = 1; i <= n; i++) {
    sx[i] = sx[i - 1] + (s[i] == 'X');
    sb[i] = sb[i - 1] + (s[i] == 'B');
    sw[i] = sw[i - 1] + (s[i] == 'W');
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = dp[i - 1][0];
    dp[i][1] = dp[i - 1][1];
    dp[i][2] = dp[i - 1][2];
    tra[i][1] = tra[i - 1][1];
    tra[i][2] = tra[i - 1][2];
    if (s[i] == 'X') {
      update(dp[i][0], dp[i - 1][0]);
      update(dp[i][1], dp[i - 1][1]);
      update(dp[i][2], dp[i - 1][2]);
    }
    if (i >= k && sb[i] - sb[i - k] == 0) {
      if (i == k || s[i - k] == 'B') {
        update(dp[i][2], dp[i - k][1]);
        update(dp[i][1], MOD - dp[i - k][1]);
        update(tra[i][2], dp[i - k][1]);
      } else if (s[i - k] == 'X') {
        tmp = ((1ll * dp[i - k][1] - (1ll * tra[i - 1][2] - tra[i - k][2])) %
                   MOD +
               MOD) %
              MOD;
        update(dp[i][2], tmp);
        update(dp[i][1], MOD - tmp);
        update(tra[i][2], tmp);
      }
    }
    if (i >= k && sw[i] - sw[i - k] == 0) {
      if (i == k || s[i - k] == 'W') {
        update(dp[i][1], dp[i - k][0]);
        update(dp[i][0], MOD - dp[i - k][0]);
        update(tra[i][1], dp[i - k][0]);
      } else if (s[i - k] == 'X') {
        tmp = ((1ll * dp[i - k][0] - (1ll * tra[i - 1][1] - tra[i - k][1])) %
                   MOD +
               MOD) %
              MOD;
        update(dp[i][1], tmp);
        update(dp[i][0], MOD - tmp);
        update(tra[i][1], tmp);
      }
    }
  }
  printf("%d\n", dp[n][2]);
  return 0;
}
