#include <bits/stdc++.h>
using namespace std;
const int N = 1000005, mod = 1000000007;
struct _two {
  int a, b;
  inline void Input(int A, int B) {
    a = A;
    b = B;
  }
} pred[N];
char ch[N];
long long f[N][3], sum[N][3];
int n, k;
void Init() {
  scanf("%d%d", &n, &k);
  scanf("%s", ch + 2);
  pred[1].Input(1, 1);
  for (int i = 2; i <= n + 1; i++) {
    pred[i].a = (ch[i - 1] == 'W') ? i - 1 : pred[i - 1].a;
    pred[i].b = (ch[i - 1] == 'B') ? i - 1 : pred[i - 1].b;
  }
}
void Work() {
  memset(f, 0, sizeof(f));
  memset(sum, 0, sizeof(sum));
  sum[1][0] = f[1][0] = 1;
  for (int i = 2; i <= n + 1; i++) {
    if (ch[i] != 'B')
      f[i][0] =
          (sum[i - 1][0] -
           sum[((pred[i].a - 1) > (i - k - 1) ? (pred[i].a - 1) : (i - k - 1))]
              [0]) %
          mod;
    sum[i][0] = (f[i][0] + sum[i - 1][0]) % mod;
    if (ch[i] != 'W' && pred[i].a <= i - k)
      if (ch[i - k] != 'B') f[i][1] = f[i - k][0];
    if (ch[i] != 'W')
      f[i][1] =
          (f[i][1] + sum[i - 1][1] -
           sum[((pred[i].b - 1) > (i - k - 1) ? (pred[i].b - 1) : (i - k - 1))]
              [1]) %
          mod;
    sum[i][1] = (sum[i - 1][1] + f[i][1]) % mod;
    if (ch[i] != 'B' && pred[i].b <= i - k)
      if (ch[i - k] != 'W') f[i][2] = f[i - k][1];
    sum[i][2] = (sum[i - 1][2] + f[i][2]) % mod;
    if (ch[i] == 'X') sum[i][2] = (sum[i][2] + sum[i - 1][2]) % mod;
  }
  if (sum[n + 1][2] < 0) sum[n + 1][2] += mod;
  printf("%d\n", sum[n + 1][2]);
}
int main() {
  Init();
  Work();
  return 0;
}
