#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-9;
const int INF = 1000000000;
const long long MOD = 1000000007;
long long mod(long long x) {
  long long res = x % MOD;
  if (res < 0) res += MOD;
  return res;
}
long long all[1024000];
long long rall[1024000];
long long no[1024000];
long long rno[1024000];
long long c1[1024000];
long long c2[1024000];
long long p[1024000];
char s[1024000];
int n, k;
int main() {
  cin >> n >> k;
  for (long long i = 1; i <= n; ++i) cin >> s[i];
  all[0] = 1;
  for (long long i = 1; i <= n; ++i) {
    all[i] = all[i - 1];
    if (s[i] == 'X') all[i] = mod(all[i] * 2);
  }
  rall[n + 1] = 1;
  for (long long i = n; i >= 1; --i) {
    rall[i] = rall[i + 1];
    if (s[i] == 'X') rall[i] = mod(rall[i] * 2);
  }
  no[0] = 1;
  int c = 0;
  for (long long i = 1; i <= n; ++i) {
    if (s[i] != 'W')
      ++c;
    else
      c = 0;
    no[i] = no[i - 1];
    if (s[i] == 'X') no[i] *= 2;
    if (i == k && c == k) --no[i];
    if (i > k && c >= k && s[i - k] != 'B') {
      no[i] -= no[i - k - 1];
    }
    no[i] = mod(no[i]);
  }
  rno[n + 1] = 1;
  c = 0;
  for (long long i = n; i >= 1; --i) {
    if (s[i] != 'B')
      ++c;
    else
      c = 0;
    rno[i] = rno[i + 1];
    if (s[i] == 'X') rno[i] *= 2;
    if (i + k - 1 == n && c == k) --rno[i];
    if (i <= n - k && c >= k && s[i + k] != 'W') {
      rno[i] -= rno[i + k + 1];
    }
    rno[i] = mod(rno[i]);
  }
  long long sum = 0;
  for (long long i = 1; i <= n; ++i) {
    if (s[i] == 'X') sum *= 2;
    c1[i] = all[i] - no[i];
    c1[i] -= sum;
    sum += c1[i];
    sum = mod(sum);
    c1[i] = mod(c1[i]);
  }
  sum = 0;
  for (long long i = n; i >= 1; --i) {
    if (s[i] == 'X') sum *= 2;
    c2[i] = rall[i] - rno[i];
    c2[i] -= sum;
    sum += c2[i];
    sum = mod(sum);
    c2[i] = mod(c2[i]);
  }
  p[n + 1] = 0;
  for (long long i = n; i >= 1; --i) p[i] = mod(c2[i] + p[i + 1]);
  long long ans = 0;
  for (long long i = 1; i <= n - 1; ++i)
    ans = mod(ans + c1[i] * (rall[i + 1] - rno[i + 1]));
  cout << ans << endl;
}
