#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 10;
const int MOD = 1000 * 1000 * 1000 + 7;
int n, k;
string s;
int dp[MAXN];
int dp1[MAXN];
int ps[MAXN];
int main() {
  cin >> n >> k;
  cin >> s;
  {
    dp[0] = 1;
    deque<int> dq;
    long long int sum = 0;
    bool tof = true;
    for (int i = 1; i <= n; i++) {
      char c = s[i - 1];
      if (c == 'X') {
        dq.push_back(i);
        sum += dp[i - 1];
        sum %= MOD;
      }
      while (dq.size() && i - dq.front() >= k) {
        sum -= dp[dq.front() - 1];
        sum %= MOD;
        dq.pop_front();
      }
      if (c == 'W') {
        dp[i] = dp[i - 1];
        dq.clear();
        sum = dp[i];
        dq.push_back(i);
        tof = false;
      } else
        dp[i] = sum;
      if (tof && i < k) dp[i] = (dp[i] + 1) % MOD;
    }
  }
  {
    dp1[n] = 1;
    deque<int> dq;
    long long int sum = 0;
    bool tof = true;
    for (int i = n - 1; i >= 0; i--) {
      char c = s[i];
      if (c == 'X') {
        dq.push_back(i);
        sum += dp1[i + 1];
        sum %= MOD;
      }
      while (dq.size() && dq.front() - i >= k) {
        sum -= dp1[dq.front() + 1];
        sum %= MOD;
        dq.pop_front();
      }
      if (c == 'B') {
        dp1[i] = dp1[i + 1];
        dq.clear();
        sum = dp1[i];
        dq.push_back(i);
        tof = false;
      } else
        dp1[i] = sum;
      if (tof && n - i < k) dp1[i] = (dp1[i] + 1) % MOD;
    }
  }
  long long int fans = 0;
  {
    ps[n] = 1;
    int last = n;
    for (int i = n - 1; i >= 0; i--) {
      ps[i] = ps[i + 1];
      if (s[i] == 'X') ps[i] = (ps[i] * 2) % MOD;
      if (s[i] == 'W') last = i;
      if (last - i >= k && (!i || s[i - 1] != 'B')) {
        long long int t = (ps[i + k] - dp1[i + k]) % MOD;
        fans += (dp[max(i - 1, 0)] * t) % MOD;
        fans %= MOD;
      }
    }
  }
  if (fans < 0) fans += MOD;
  cout << fans << endl;
  return 0;
}
