#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n, k;
char s[1000005];
int Bsum[1000005], Wsum[1000005];
int Bfree[1000005], Wfree[1000005];
int lmost[1000005], rmost[1000005];
int main() {
  scanf("%d %d\n%s", &n, &k, s + 1);
  for (int i = 1; i <= n + 1; ++i) {
    Bsum[i] = Bsum[i - 1] + (s[i] == 'B');
    Wsum[i] = Wsum[i - 1] + (s[i] == 'W');
  }
  Bfree[0] = 1;
  for (int i = 1; i <= n; ++i) {
    lmost[i] = 0;
    if (i >= k && Wsum[i] == Wsum[i - k])
      if (s[i - k] != 'B') lmost[i] = Bfree[max(i - k - 1, 0)];
    int tmp = Bfree[i - 1];
    if (s[i] == 'X') tmp = (tmp * 2) % mod;
    tmp = (tmp - lmost[i] + mod) % mod;
    Bfree[i] = tmp;
  }
  Wfree[n + 1] = 1;
  for (int i = n; i >= 1; --i) {
    rmost[i] = 0;
    if (i <= n - k + 1 && Bsum[i + k - 1] == Bsum[i - 1])
      if (s[i + k] != 'W') rmost[i] = Wfree[min(i + k + 1, n + 1)];
    int tmp = Wfree[i + 1];
    if (s[i] == 'X') tmp = (tmp * 2) % mod;
    tmp = (tmp - rmost[i] + mod) % mod;
    Wfree[i] = tmp;
  }
  long long ans = 0;
  int cnt = 1;
  for (int i = n; i >= 1; --i) {
    if (s[i] == 'X') cnt = cnt * 2 % mod;
    int hasW = (cnt - Wfree[i] + mod) % mod;
    ans += (1ll * lmost[i - 1] * hasW) % mod;
  }
  ans %= mod;
  printf("%lld\n", ans);
  return 0;
}
