#include <bits/stdc++.h>
using namespace std;
int N, K;
string s;
int Bsum[1000010], Wsum[1000010];
long long leftmost[1000010], Bfree[1000010], rightmost[1000010], Wfree[1000010];
void dp_left(void) {
  int i;
  Bfree[0] = 1;
  for (i = 1; i <= N; i++) {
    if (i >= K && Wsum[i] - Wsum[i - K] == 0)
      if (i == K || s[i - K - 1] != 'B') leftmost[i] = Bfree[max(i - K - 1, 0)];
    long long tmp = Bfree[i - 1];
    if (s[i - 1] == 'X') tmp = tmp * 2 % 1000000007ll;
    tmp = (tmp - leftmost[i] + 1000000007ll) % 1000000007ll;
    Bfree[i] = tmp;
  }
}
void dp_right(void) {
  int i;
  Wfree[N] = 1;
  for (i = N - 1; i >= 0; i--) {
    if (i <= N - K && Bsum[i + K] - Bsum[i] == 0)
      if (i == N - K || s[i + K] != 'W')
        rightmost[i] = Wfree[min(i + K + 1, N)];
    long long tmp = Wfree[i + 1];
    if (s[i] == 'X') tmp = tmp * 2 % 1000000007ll;
    tmp = (tmp - rightmost[i] + 1000000007ll) % 1000000007ll;
    Wfree[i] = tmp;
  }
}
int main(void) {
  int i;
  cin >> N >> K >> s;
  for ((i) = 0; (i) < (int)(N); (i)++)
    Bsum[i + 1] = Bsum[i] + ((s[i] == 'B') ? 1 : 0);
  for ((i) = 0; (i) < (int)(N); (i)++)
    Wsum[i + 1] = Wsum[i] + ((s[i] == 'W') ? 1 : 0);
  dp_left();
  dp_right();
  long long ans = 0;
  long long two = 1;
  for (i = N - 1; i >= 0; i--) {
    if (s[i] == 'X') two = two * 2 % 1000000007ll;
    long long containW = (two - Wfree[i] + 1000000007ll) % 1000000007ll;
    ans = (ans + leftmost[i] * containW) % 1000000007ll;
  }
  cout << ans << endl;
  return 0;
}
