#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005, MOD = 1000000007;
int n, limit;
long long Pow[maxn], L[maxn], R[maxn];
char pat[maxn];
int main() {
  Pow[0] = 1;
  for (int i = 1; i < maxn; i++) Pow[i] = Pow[i - 1] * 2 % MOD;
  while (~scanf("%d %d", &n, &limit)) {
    scanf("%s", pat + 1);
    long long cntX = 0, cntW = 0, sumL = 0, dec = 0;
    for (int i = 1; i <= n; i++) {
      cntW += pat[i] == 'W';
      if (i > limit) cntW -= pat[i - limit] == 'W';
      if (i > limit) cntX += pat[i - limit] == 'X';
      if (i > 1) sumL = (sumL + L[i - 1]) % MOD;
      if (i > limit) sumL = (sumL - L[i - limit] + MOD) % MOD;
      if (i > limit && pat[i - limit] == 'X') dec = dec * 2 % MOD;
      if (i > limit) dec = (dec + L[i - limit]) % MOD;
      if (i >= limit && cntW == 0)
        L[i] = (Pow[cntX] - sumL - dec + MOD) % MOD;
      else
        L[i] = 0;
    }
    long long cntB = 0, sumR = 0;
    cntX = 0, dec = 0;
    for (int i = n; i >= 1; i--) {
      cntB += pat[i] == 'B';
      if (i + limit <= n) cntB -= pat[i + limit] == 'B';
      if (i + limit <= n) cntX += pat[i + limit] == 'X';
      if (i < n) sumR = (sumR + R[i + 1]) % MOD;
      if (i + limit <= n) sumR = (sumR - R[i + limit] + MOD) % MOD;
      if (i + limit <= n && pat[i + limit] == 'X') dec = dec * 2 % MOD;
      if (i + limit <= n) dec = (dec + R[i + limit]) % MOD;
      if (i + limit - 1 <= n && cntB == 0)
        R[i] = (Pow[cntX] - sumR - dec + MOD) % MOD;
      else
        R[i] = 0;
    }
    long long res = 0, sum = 0;
    for (int i = n; i >= 1; i--) {
      res = (res + L[i] * sum) % MOD;
      if (pat[i] == 'X') sum = sum * 2 % MOD;
      sum = (sum + R[i]) % MOD;
    }
    printf("%d\n", (int)res);
  }
  return 0;
}
