#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
const long long mod = 1000000007;
long long dp[N], f[N], a[N], b[N];
char s[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  scanf("%s", s + 1);
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  dp[0] = 1;
  int tot = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'W')
      tot = 0;
    else
      tot++;
    if (s[i] == 'X')
      dp[i] = dp[i - 1] * 2 % mod;
    else
      dp[i] = dp[i - 1];
    if (tot >= m) {
      if (i == m) {
        dp[i]--;
        a[i] = 1;
      } else if (s[i - m] != 'B') {
        dp[i] = (dp[i] - dp[i - m - 1]) % mod;
        a[i] = dp[i - m - 1];
      }
    }
  }
  f[n + 1] = 1, tot = 0;
  for (int i = n; i >= 1; i--) {
    if (s[i] == 'B')
      tot = 0;
    else
      tot++;
    if (s[i] == 'X') {
      f[i] = f[i + 1] * 2 % mod;
      b[i] = b[i + 1] * 2 % mod;
    } else {
      f[i] = f[i + 1];
      b[i] = b[i + 1];
    }
    if (tot >= m) {
      if (i + m - 1 == n) {
        b[i] = 1;
        f[i]--;
      } else {
        if (s[i + m] != 'W') {
          f[i] = (f[i] - f[i + m + 1]) % mod;
          b[i] = (b[i] + f[i + m + 1]) % mod;
        }
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans = (ans + a[i] * b[i + 1]) % mod;
  ans = (ans + mod) % mod;
  printf("%I64d\n", ans);
  return 0;
}
