#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int maxn = 2000000;
int l, lsub;
char str[maxn + 1];
long long dpw[maxn + 1], dpb[maxn + 1], now, nob, ans0, ansb, ans, ranansb,
    ranans0;
int main() {
  scanf("%d%d", &l, &lsub);
  scanf("%s", str);
  now = -1;
  nob = -1;
  for (long long i = 0; i < l; i++) ans0 = 1;
  for (long long i = 0; i < l; i++) {
    if (str[i] == 'X') {
      long long temp = 0;
      if (i - now >= lsub) {
        temp = 1;
        if (i >= lsub) temp = dpw[i - lsub];
      }
      ranans0 = ans0 * 2 - temp;
      while (ranans0 < 0) ranans0 += mod;
      long long temp1 = 0;
      if (i - nob >= lsub) {
        if (i >= lsub) temp1 = dpb[i - lsub];
      }
      ranansb = ansb * 2 + temp - temp1;
      while (ranansb < 0) ranansb += mod;
      ans *= 2;
      ans %= mod;
      ans += temp1;
      ans %= mod;
      dpw[i] = ans0 % mod;
      dpb[i] = (ansb + temp) % mod;
      ans0 = ranans0 % mod;
      ansb = ranansb % mod;
    }
    if (str[i] == 'B') {
      long long temp = 0;
      if (i - now >= lsub) {
        temp = 1;
        if (i >= lsub) temp = dpw[i - lsub];
      }
      nob = i;
      ranans0 = ans0 - temp;
      while (ranans0 < 0) ranans0 += mod;
      ranansb = ansb + temp;
      dpw[i] = 0;
      dpb[i] = (ansb + temp) % mod;
      ans0 = ranans0 % mod;
      ansb = ranansb % mod;
    }
    if (str[i] == 'W') {
      long long temp1 = 0;
      if (i - nob >= lsub) {
        if (i >= lsub) temp1 = dpb[i - lsub];
      }
      now = i;
      ranans0 = ans0;
      ranansb = ansb - temp1;
      while (ranansb < 0) ranansb += mod;
      ans += temp1;
      ans %= mod;
      dpw[i] = ans0 % mod;
      dpb[i] = 0;
      ans0 = ranans0 % mod;
      ansb = ranansb % mod;
    }
  }
  cout << ans << endl;
  return 0;
}
