#include <bits/stdc++.h>
using namespace std;
int n, k;
char s[1000005];
int mod = 1000000007;
int fb[1000005], fw[1000005];
int sumb[1000005], sumw[1000005];
void getmod(int &a) {
  a %= mod;
  a += mod;
  a %= mod;
}
int main() {
  scanf("%d%d%s", &n, &k, s);
  sumb[0] = sumw[0] = 0;
  for (int i = 0; i < n; i++) {
    sumb[i + 1] = sumb[i];
    sumw[i + 1] = sumw[i];
    if (s[i] == 'B') sumb[i + 1]++;
    if (s[i] == 'W') sumw[i + 1]++;
  }
  fb[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (s[i - 1] == 'X')
      fb[i] = fb[i - 1] * 2;
    else
      fb[i] = fb[i - 1];
    getmod(fb[i]);
    if (i - k >= 0 && sumw[i] == sumw[i - k]) {
      if (i - k - 1 >= 0 && s[i - k - 1] != 'B')
        fb[i] -= fb[i - k - 1];
      else if (i - k == 0)
        fb[i]--;
    }
    getmod(fb[i]);
  }
  fw[n + 1] = 1;
  for (int i = n; i >= 1; i--) {
    if (s[i - 1] == 'X')
      fw[i] = fw[i + 1] * 2;
    else
      fw[i] = fw[i + 1];
    getmod(fw[i]);
    if (i + k <= n + 1 && sumb[i - 1] == sumb[i + k - 1]) {
      if (i + k <= n && s[i + k - 1] != 'W')
        fw[i] -= fw[i + k + 1];
      else if (i + k == n + 1)
        fw[i]--;
    }
    getmod(fw[i]);
  }
  int ret = 0;
  int tot = 0;
  for (int i = n - 2 * k; i >= 0; i--) {
    if (s[i + k] == 'X') tot *= 2;
    getmod(tot);
    if (s[i + k * 2] != 'W' && sumb[i + k * 2] == sumb[i + k]) {
      if (s[i + k * 2] == 'X')
        tot += fw[i + k * 2 + 2];
      else
        tot += fw[i + k * 2 + 1];
    }
    getmod(tot);
    if ((i - 1 < 0 || s[i - 1] != 'B') && sumw[i + k] == sumw[i]) {
      if (i - 1 >= 0 && s[i - 1] == 'X')
        ret += (fb[i - 1] * 1LL * tot) % mod;
      else
        ret += (fb[i] * 1LL * tot) % mod;
    }
    getmod(ret);
  }
  printf("%d\n", ret);
}
