#include <bits/stdc++.h>
using namespace std;
char s[2000001];
long long n, m, i, j, ans, hh, ab[2000001], aw[2000001], ax[2000001],
    fac[2000001], fw[2000001], fb[2000001], p = 1e9 + 7, sumb[2000001],
                                            sumw[2000001];
int main() {
  scanf("%lld%lld", &n, &m);
  fac[0] = 1;
  for (i = 1; i <= n; i++) fac[i] = fac[i - 1] * 2 % p;
  if (n < m * 2) return puts("0"), 0;
  scanf("%s", s + 1);
  for (i = 1; i <= n; i++) {
    if (s[i] == 'B' || s[i] == 'X') ab[i] = 1;
    if (s[i] == 'W' || s[i] == 'X') aw[i] = 1;
    if (s[i] == 'X') ax[i] = 1;
    ab[i] += ab[i - 1];
    aw[i] += aw[i - 1];
    ax[i] += ax[i - 1];
  }
  for (i = m; i <= n; i++) {
    if (ab[i] - ab[i - m] == m && (i == m || s[i - m] != 'B')) {
      fb[i] = (fac[i == m ? 0 : ax[i - m - 1]] -
               (i == m ? 0 : sumb[i - m - 1]) + p) %
              p;
    }
    sumb[i] = (sumb[i - 1] + fb[i]) % p;
    if (s[i] == 'X') sumb[i] = (sumb[i] + sumb[i - 1]) % p;
  }
  for (i = n - m + 1; i; i--) {
    if (aw[i + m - 1] - aw[i - 1] == m && (i == n - m + 1 || s[i + m] != 'W')) {
      fw[i] = (fac[i == n - m + 1 ? 0 : ax[n] - ax[i + m]] -
               (i >= n - m ? 0 : sumw[i + m + 1]) + p) %
              p;
    }
    sumw[i] = (sumw[i + 1] + fw[i]) % p;
    if (s[i] == 'X') sumw[i] = (sumw[i] + sumw[i + 1]) % p;
  }
  hh = fb[m];
  for (i = m + 1; i <= n - m + 1; i++) {
    ans = (ans + hh * fw[i] % p) % p;
    if (s[i] == 'X') hh = hh * 2 % p;
    hh = (hh + fb[i]) % p;
  }
  printf("%lld", ans);
}
