#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
int n, k;
char s[1000100];
int Bsum[1000100], Wsum[1000100];
int Bfree[1000100], Wfree[1000100];
int lmost[1000100], rmost[1000100];
void do_left() {
  Bfree[0] = 1;
  for (int i = 1; i <= n; i++) {
    lmost[i] = 0;
    if (i >= k && Wsum[i] - Wsum[i - k] == 0) {
      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;
  }
}
void do_right() {
  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] == 0) {
      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;
  }
}
int main() {
  cin >> n >> k;
  scanf("%s", 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');
  }
  do_left();
  do_right();
  long long sum = 0ll;
  int two = 1;
  for (int i = n; i >= 1; i--) {
    if (s[i] == 'X') two = (two * 2) % Mod;
    int hasW = (two - Wfree[i] + Mod) % Mod;
    sum += (1ll * lmost[i - 1] * hasW) % Mod;
  }
  sum %= Mod;
  cout << sum << endl;
  return 0;
}
