#include <bits/stdc++.h>
const int N = 2000005, oo = 1000000007;
int n, k, m, r, sum, ans, f[N], g[N], p[N];
char s[N];
int main() {
  scanf("%d%d%s", &n, &k, s + 1), p[n + 1] = f[m = r = n] = sum = 1;
  for (int i = n; i; i--) p[i] = p[i + 1] * (1 + (s[i] == 'X')) % oo;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'B') m--;
    if (s[i] == 'W') f[r = m] = sum;
    if (s[i] == 'X') f[--m] = sum, sum = sum * 2 % oo;
    if (r - m == k) g[i] = f[r], sum = (sum - f[r--]) % oo;
  }
  memset(f, 0, sizeof(f)), sum = 0, m = r = n;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'W') m--;
    if (s[i] == 'B') f[r = m] = sum;
    if (s[i] == 'X') f[--m] = sum, sum = sum * 2 % oo;
    if (r - m == k)
      ans = (1LL * p[i + 1] * f[r] + ans) % oo, sum = (sum - f[r--]) % oo;
    f[m] = (f[m] + g[i]) % oo, sum = (sum + g[i]) % oo;
  }
  printf("%d\n", (ans + oo) % oo);
  return 0;
}
