#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 20;
int n, k;
char st[N];
const long long mod = 1e9 + 7;
long long po[N], sum[N], f[N], g[N], t1[N], t2[N];
int main() {
  scanf("%d%d", &n, &k);
  scanf("%s", st + 1);
  po[0] = 1;
  int s;
  for (int i = 1; i <= n; i++) {
    if (st[i] == 'W')
      s = 0;
    else
      s++;
    if (s >= k) {
      f[i] = ((po[i - k] - t1[i - k] + mod) % mod -
              (sum[i - 1] - sum[i - k] + mod) % mod + mod) %
             mod;
    }
    if (st[i] == 'X')
      po[i] = po[i - 1] * 2 % mod, t1[i] = (t1[i - 1] * 2 + f[i]) % mod;
    else
      po[i] = po[i - 1], t1[i] = (t1[i - 1] + f[i]) % mod;
    sum[i] = (sum[i - 1] + f[i]) % mod;
  }
  po[n + 1] = 1;
  s = 0;
  for (int i = n; i >= 1; i--) {
    if (st[i] == 'B')
      s = 0;
    else
      s++;
    if (s >= k) {
      g[i] = ((po[i + k] - t2[i + k] + mod) % mod -
              (sum[i + 1] - sum[i + k] + mod) % mod + mod) %
             mod;
    }
    if (st[i] == 'X')
      po[i] = (po[i + 1] * 2) % mod;
    else
      po[i] = po[i + 1];
    if (st[i] == 'X')
      t2[i] = (t2[i + 1] * 2 + g[i]) % mod;
    else
      t2[i] = (t2[i + 1] + g[i]) % mod;
    sum[i] = (sum[i + 1] + g[i]) % mod;
  }
  long long ans = 0;
  for (int i = 1; i < n; i++) ans = (ans + f[i] * t2[i + 1]) % mod;
  printf("%lld\n", ans);
  return 0;
}
