#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 2000005;
int pref[N], suf[N];
int lB[N], lW[N];
int arr[N];
int S[N][4];
int n, k;
char s[N];
int pw[N];
int value[N];
int summary;
int mPow(int x, int n, int mod) {
  if (n == 0) return 1;
  if (n % 2) return 1LL * x * mPow(x, n - 1, mod) % mod;
  int value = mPow(x, n / 2, mod);
  return 1LL * value * value % mod;
}
int get(int hsfkasfhasfuckajsfkjsaf, int ajadslfkjasdklfj, int x) {
  return S[ajadslfkjasdklfj][x] -
         (hsfkasfhasfuckajsfkjsaf ? S[hsfkasfhasfuckajsfkjsaf - 1][x] : 0);
}
int main() {
  scanf("%d%d\n", &n, &k);
  scanf("%s", s);
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'X')
      arr[i + 1] = 0;
    else if (s[i] == 'B')
      arr[i + 1] = 1;
    else
      arr[i + 1] = 2;
  }
  int lastB = -1, lastW = -1;
  for (int i = 0; i < n; ++i) {
    if (arr[i + 1] == 1)
      lastB = i + 1;
    else if (arr[i + 1] == 2)
      lastW = i + 1;
    lB[i + 1] = lastB;
    lW[i + 1] = lastW;
  }
  int cur[3] = {0, 0, 0};
  for (int i = 0; i < n; ++i) {
    cur[arr[i + 1]]++;
    for (int j = 0; j < 3; ++j) S[i + 1][j] = cur[j];
  }
  if (n < k + k) {
    puts("0");
    return 0;
  }
  pref[0] = 1;
  for (int i = 1; i <= n; ++i) {
    pref[i] = pref[i - 1];
    if (arr[i] == 0) pref[i] = (pref[i] + pref[i - 1]) % mod;
    if (i >= k) {
      if (lW[i] <= i - k && arr[i - k] != 1)
        pref[i] =
            (pref[i] - (i - k - 1 >= 0 ? pref[i - k - 1] : 1) + mod) % mod;
    }
  }
  suf[n + 1] = 1;
  for (int i = n; i >= 1; --i) {
    suf[i] = suf[i + 1];
    if (arr[i] == 0) suf[i] = (suf[i] + suf[i + 1]) % mod;
    if (i + k - 1 <= n) {
      if (lB[i + k - 1] <= i - 1 && arr[i + k] != 2)
        suf[i] =
            (suf[i] - (i + k + 1 <= n + 1 ? suf[i + k + 1] : 1) + mod) % mod;
    }
  }
  pw[0] = 1;
  for (int i = 1; i <= n; ++i) {
    pw[i] = (pw[i - 1] + pw[i - 1]) % mod;
  }
  for (int i = k + 1; i <= n; ++i) {
    if (i + k - 1 > n) continue;
    value[i] = mPow(pw[get(i, n, 0)], mod - 2, mod);
    value[i] = 1LL * value[i] * suf[i + k + 1] % mod;
  }
  int answer = 0;
  int summary = 0;
  for (int i = k + 1; i <= n; ++i) {
    if (i + k - 1 > n || arr[i + k] == 2) continue;
    summary = (summary + value[i]) % mod;
  }
  for (int i = 1; i <= n; ++i) {
    if (i + k - 1 > n) break;
    if (lW[i + k - 1] < i && arr[i - 1] != 1) {
      int ret = 1LL * ((pw[get(i + k, n, 0)] - suf[i + k] + mod) % mod) *
                (i - 2 >= 0 ? pref[i - 2] : 1) % mod;
      answer = (answer + ret % mod) % mod;
    }
    summary = (summary - value[i + k] + mod) % mod;
  }
  printf("%d\n", answer);
  return 0;
}
