#include <bits/stdc++.h>
using namespace std;
void read(int& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
char getc() {
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  return c;
}
const int de = 1000001;
const int N = 2000010;
const int mod = 1000000007;
int n, m, i, j, l, ans;
char str[N];
int two[N], s[N];
int F0[N], F1[N];
int tot0, tot1, la0, la1;
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", str + 1);
  two[0] = 1;
  for (i = 1; i <= n; i++) two[i] = two[i - 1] * 2 % mod;
  for (i = 1; i <= n; i++) s[i] = s[i - 1] + (str[i] == 'X');
  int* f0 = F0 + de;
  int* f1 = F1 + de;
  f0[0] = 1;
  tot0 = 1;
  for (i = 1; i <= n; i++) {
    if (str[i] == 'B') {
      la1 = -i;
      f1[-i] = tot1;
    }
    if (str[i] == 'W') {
      la0 = -i;
      f0[-i] = tot0;
    }
    if (str[i] == 'X') {
      f0[-i] = tot0;
      tot0 = ((tot0) + (f0[-i])) % mod;
      f1[-i] = tot1;
      tot1 = ((tot1) + (f1[-i])) % mod;
    }
    if (-i + m <= la0) {
      f1[-i] = ((f1[-i]) + (f0[-i + m])) % mod;
      tot1 = ((tot1) + (f0[-i + m])) % mod;
      tot0 = ((tot0) + (-f0[-i + m])) % mod;
      f0[-i + m] = 0;
    }
    if (-i + m <= la1) {
      ans = (ans + 1LL * f1[-i + m] * two[s[n] - s[i]]) % mod;
      tot1 = ((tot1) + (-f1[-i + m])) % mod;
      f1[-i + m] = 0;
    }
  }
  printf("%d\n", (ans % mod + mod) % mod);
  scanf("\n");
  return 0;
}
