#include <bits/stdc++.h>
using namespace std;
template <class T>
void input(T &x) {
  char c = getchar();
  x = 0;
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
}
inline long long bigmod(long long p, long long e, long long M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
const int N = 1e6 + 6;
char str[N];
int k, n;
const int MOD = 1e9 + 7;
vector<long long> W, B, X;
int NoW(int x, int y) {
  if (x > y) return 1;
  if (W[y] - W[x - 1] == 0) return 1;
  return 0;
}
int NoB(int x, int y) {
  if (x > y) return 1;
  if (B[y] - B[x - 1] == 0) return 1;
  return 0;
}
int getX(int x, int y) {
  if (x > y) return 0;
  return X[y] - X[x - 1];
}
int main() {
  cin >> n >> k >> str + 1;
  vector<long long> push_back(n + 2, 0), pw(n + 2, 0), sb(n + 2, 0),
      sw(n + 2, 0);
  push_back[0] = 0;
  pw[0] = 1;
  W.resize(n + 2, 0), B.resize(n + 2, 0), X.resize(n + 2, 0);
  for (int i = 1; i <= n; i++) {
    W[i] = W[i - 1], B[i] = B[i - 1], X[i] = X[i - 1];
    if (str[i] == 'B') B[i]++;
    if (str[i] == 'W') W[i]++;
    if (str[i] == 'X') X[i]++;
    if (str[i] == 'B') {
      pw[i] = 0;
      push_back[i] = push_back[i - 1] + pw[i - 1];
      if (i - k + 1 >= 1 && NoW(i - k + 1, i)) {
        push_back[i] -= pw[i - k];
      }
    } else if (str[i] == 'W') {
      push_back[i] = 0;
      pw[i] = push_back[i - 1] + pw[i - 1];
    } else {
      push_back[i] = push_back[i - 1] + pw[i - 1];
      pw[i] = push_back[i - 1] + pw[i - 1];
      if (i - k + 1 >= 1 && NoW(i - k + 1, i)) {
        push_back[i] -= pw[i - k];
      }
    }
    push_back[i] = (push_back[i] % MOD + MOD) % MOD;
    pw[i] = (pw[i] % MOD + MOD) % MOD;
  }
  sb[n + 1] = 1, sw[n + 1] = 0;
  for (int i = n; i >= 1; i--) {
    if (str[i] == 'B') {
      sb[i] = sb[i + 1] + sw[i + 1];
      sw[i] = 0;
    } else if (str[i] == 'W') {
      sb[i] = 0;
      sw[i] = sw[i + 1] + sb[i + 1];
      if (i + k - 1 <= n && NoB(i, i + k - 1)) sw[i] -= sb[i + k];
    } else {
      sb[i] = sb[i + 1] + sw[i + 1];
      sw[i] = sw[i + 1] + sb[i + 1];
      if (i + k - 1 <= n && NoB(i, i + k - 1)) sw[i] -= sb[i + k];
    }
    sw[i] = (sw[i] % MOD + MOD) % MOD;
    sb[i] = (sb[i] % MOD + MOD) % MOD;
  }
  long long add = 0;
  vector<pair<int, long long> > V;
  for (int j = 1; j + k - 1 <= n; j++) {
    if (NoB(j, j + k - 1)) {
      V.push_back(make_pair(j, sb[j + k]));
    }
  }
  int ptr = V.size() - 1;
  long long ans = 0;
  for (int i = n; i >= k; i--) {
    if (NoW(i - k + 1, i)) {
      ans += (pw[i - k] * add) % MOD;
    }
    if (str[i] == 'X') add = (add * 2) % MOD;
    if (ptr >= 0 && V[ptr].first == i) add = (add + V[ptr].second) % MOD, ptr--;
    ans %= MOD;
  }
  cout << ans % MOD << endl;
  return 0;
}
