#include <bits/stdc++.h>
using namespace std;
long long i, j, k, l, n, m, s, an, sum, K, C, tt, tot;
const long long N = 2100000;
const long long pp = 1000000007;
long long f[N], g[N], anl[N], anr[N], S[N], er[N], chu[N];
char a[N];
long long quick(long long x, long long y) {
  long long xx = 1;
  while (y) {
    if (y & 1) xx = xx * x % pp;
    x = x * x % pp;
    y /= 2;
  }
  return xx;
}
int main() {
  scanf("%I64d%I64d", &n, &K);
  scanf("%s", a + 1);
  er[0] = 1;
  for (long long i = 1; i <= n; i++) er[i] = er[i - 1] * 2 % pp;
  chu[n] = quick(er[n], pp - 2);
  for (long long i = n - 1; i >= 0; i--) chu[i] = chu[i + 1] * 2 % pp;
  for (long long i = 1; i <= n; i++) S[i] = S[i - 1] + (a[i] == 'X');
  long long l = n;
  f[l] = 1;
  sum = 1;
  for (long long i = 1; i <= n; i++) {
    if (a[i] == 'W') {
      for (long long j = l; j <= n; j++) f[j] = 0;
      l = n;
      f[l] = sum;
    } else {
      l--;
      if (a[i] == 'X') f[l] = sum, sum += f[l], sum %= pp;
    }
    anl[i] = f[l + K];
    anl[i] %= pp;
    sum -= f[l + K];
    sum = (sum % pp + pp) % pp;
  }
  memset(f, 0, sizeof(f));
  l = n;
  f[l] = 1;
  sum = 1;
  for (long long i = n; i >= 1; i--) {
    if (a[i] == 'B') {
      for (long long j = l; j <= n; j++) f[j] = 0;
      l = n;
      f[l] = sum;
    } else {
      l--;
      if (a[i] == 'X') f[l] = sum, sum += f[l], sum %= pp;
    }
    anr[i] = f[l + K];
    anr[i] %= pp;
    sum -= f[l + K];
    sum = (sum % pp + pp) % pp;
  }
  long long s2 = 0;
  for (long long i = 1; i <= n; i++) s2 += anr[i] * er[S[i - 1]] % pp, s2 %= pp;
  for (long long i = 1; i <= n; i++) {
    s2 -= anr[i] * er[S[i - 1]] % pp, s2 = (s2 % pp + pp) % pp;
    an += anl[i] * s2 % pp * chu[S[i]] % pp, an %= pp;
  }
  printf("%I64d\n", (an + pp) % pp);
  return 0;
}
