#include <bits/stdc++.h>
using namespace std;
const int mo = 1000000007;
int i, j, k, l, n, m, f[1200000], g[1200000], sum, r, ans, a[1200000];
char c[1200000];
int main() {
  scanf("%d%d%s", &n, &k, c + 1);
  f[m = r = n] = sum = 1;
  a[n + 1] = 1;
  for (i = n; i >= 1; --i)
    if (c[i] == 'X')
      a[i] = (a[i + 1] + a[i + 1]) % mo;
    else
      a[i] = a[i + 1];
  for (i = 1; i <= n; ++i) {
    if (c[i] == 'B') m--;
    if (c[i] == 'W') f[r = m] = sum;
    if (c[i] == 'X') f[--m] = sum, sum = (sum + sum) % mo;
    if (r - m == k) g[i] = f[r], sum = (sum - f[r--]) % mo;
  }
  memset(f, 0, sizeof(f));
  f[m = r = n] = sum = 0;
  for (i = 1; i <= n; ++i) {
    if (c[i] == 'B') f[r = m] = sum;
    if (c[i] == 'W') m--;
    if (c[i] == 'X') f[--m] = sum, sum = (sum + sum) % mo;
    if (r - m == k)
      ans = (1ll * f[r] * a[i + 1] + ans) % mo, sum = (sum - f[r--]) % mo;
    f[m] = (f[m] + g[i]) % mo;
    sum = (sum + g[i]) % mo;
  }
  printf("%d\n", (ans + mo) % mo);
}
