#include <bits/stdc++.h>
using namespace std;
int stmp;
const int MAX = 1000010;
const int INF = 1000000001;
const int MOD = 1000000007;
char A[MAX];
int Wsum[MAX], Bsum[MAX], Xsum[MAX];
long long Wcnt[MAX], Bcnt[MAX];
long long p2[MAX];
int n, k;
int main(int argc, char *argv[]) {
  p2[0] = 1;
  for (int i = (1); i <= (MAX - 1); ++i) p2[i] = (p2[i - 1] * 2LL) % MOD;
  stmp = scanf("%d %d", &n, &k);
  stmp = scanf("%s", A + 1);
  for (int i = (1); i <= (n); ++i) {
    Wsum[i] = Wsum[i - 1] + (A[i] == 'W');
    Bsum[i] = Bsum[i - 1] + (A[i] == 'B');
    Xsum[i] = Xsum[i - 1] + (A[i] == 'X');
  }
  Xsum[n + 1] = Xsum[n];
  Wcnt[n + 1] = Wcnt[n + 2] = 1;
  for (int i = (n); i >= (1); --i) {
    if (A[i] == 'X')
      Wcnt[i] = (Wcnt[i + 1] * 2LL) % MOD;
    else
      Wcnt[i] = Wcnt[i + 1];
    if (A[i] != 'B' && i + k - 1 <= n) {
      if (Bsum[i + k - 1] - Bsum[i - 1] == 0)
        if (A[i + k] != 'W') Wcnt[i] = (Wcnt[i] - Wcnt[i + k + 1] + MOD) % MOD;
    }
  }
  for (int i = (1); i <= (n + 1); ++i)
    Wcnt[i] = (p2[Xsum[n] - Xsum[i - 1]] - Wcnt[i] + MOD) % MOD;
  long long res = 0;
  Bcnt[0] = 1;
  for (int i = (1); i <= (n); ++i) {
    if (A[i] == 'X')
      Bcnt[i] = (Bcnt[i - 1] * 2LL) % MOD;
    else
      Bcnt[i] = Bcnt[i - 1];
    if (A[i] != 'W' && i - k >= 0) {
      if (Wsum[i] - Wsum[i - k] == 0)
        if (A[i - k] != 'B')
          Bcnt[i] = (Bcnt[i] - Bcnt[max(0, i - k - 1)] + MOD) % MOD;
    }
  }
  for (int i = (k); i <= (n); ++i) {
    if (Wsum[i] - Wsum[i - k] == 0) {
      if (i == k || A[i - k] != 'B')
        res = (res + Bcnt[max(0, i - k - 1)] * Wcnt[i + 1]) % MOD;
    }
  }
  res = (res + MOD) % MOD;
  printf("%d\n", (int)res);
  return 0;
}
