#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:60777216")
const int N = 1111111;
char s[N];
int n, k;
const int mod = 1000000007;
int f[N], g[N], h[N], ps[N], pW[N], pX[N], pB[N], p2[N], pr[N];
inline void solve(int *f, int *g, char W, char B, char X) {
  pW[0] = pX[0] = pB[0] = 0;
  if (s[0] == W)
    pW[0] = 1;
  else if (s[0] == B)
    pB[0] = 1;
  else if (s[0] == X)
    pX[0] = 1;
  for (int i = 1; i < n; ++i) {
    pW[i] = pW[i - 1];
    pB[i] = pB[i - 1];
    pX[i] = pX[i - 1];
    if (s[i] == W)
      pW[i]++;
    else if (s[i] == B)
      pB[i]++;
    else if (s[i] == X)
      pX[i]++;
  }
  f[0] = 0;
  g[0] = 0;
  if (k == 1) {
    if (s[0] == W || s[0] == X) {
      f[0]++;
    }
    if (s[0] == B || s[0] == X) {
      g[0]++;
    }
  } else {
    g[0]++;
    if (s[0] == X) g[0]++;
  }
  ps[0] = 0;
  if (s[0] == X) ps[0] = 1;
  int lb = -1;
  if (s[0] == B) lb = 0;
  for (int i = 1; i < n; ++i) {
    if (i >= k - 1) {
      int cW = pW[i];
      if (i > k - 1) cW -= pW[i - k];
      int cB = pB[i];
      if (i > k - 1) cB -= pB[i - k];
      int cX = pX[i];
      if (i > k - 1) cX -= pX[i - k];
      if (cB == 0) {
        if (i == k - 1)
          f[i] = 1;
        else {
          if (s[i - k] == B) {
            f[i] = g[i - k];
          } else if (s[i - k] == W) {
            f[i] = 0;
          } else {
            if (i == k)
              f[i] = 1;
            else
              f[i] = g[i - k - 1];
          }
        }
      } else
        f[i] = 0;
      g[i] = 0;
      if (s[i] == B || s[i] == X) g[i] += g[i - 1];
      if (s[i] == W || s[i] == X) {
        if (cB) {
          g[i] += ps[i - 1];
          if (g[i] >= mod) g[i] -= mod;
          g[i] += mod - ps[lb];
          if (g[i] >= mod) g[i] -= mod;
          g[i] += g[lb];
          if (g[i] >= mod) g[i] -= mod;
        } else {
          g[i] += ps[i - 1];
          if (g[i] >= mod) g[i] -= mod;
          if (i >= k) {
            g[i] += mod - ps[i - k];
            if (g[i] >= mod) g[i] -= mod;
          }
        }
      }
    } else {
      f[i] = 0;
      g[i] = p2[pX[i]];
    }
    ps[i] = ps[i - 1];
    if (s[i] == 'X') ps[i] += g[i - 1];
    if (ps[i] >= mod) ps[i] -= mod;
    if (s[i] == B) lb = i;
  }
}
inline long long solution() {
  solve(f, h, 'B', 'W', 'X');
  reverse(s, s + n);
  solve(g, h, 'W', 'B', 'X');
  reverse(g, g + n);
  reverse(s, s + n);
  pX[0] = 0;
  if (s[0] == 'X') pX[0] = 1;
  for (int i = 1; i < n; ++i) {
    pX[i] = pX[i - 1];
    if (s[i] == 'X') pX[i]++;
  }
  for (int i = 1; i < n; ++i) {
    g[i] = ((long long)g[i] * p2[pX[i - 1]]) % mod;
  }
  ps[n - 1] = g[n - 1];
  for (int i = n - 2; i >= 0; --i) {
    ps[i] = ps[i + 1] + g[i];
    if (ps[i] >= mod) ps[i] -= mod;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int cur = ((long long)f[i] * ps[i + 1]) % mod;
    cur = ((long long)cur * pr[pX[i]]) % mod;
    ans = (ans + cur) % mod;
  }
  return ans;
}
int main() {
  gets(s);
  sscanf(s, "%d%d", &n, &k);
  gets(s);
  p2[0] = 1;
  for (int i = 1; i <= n; ++i) {
    p2[i] = p2[i - 1] * 2;
    if (p2[i] >= mod) p2[i] -= mod;
  }
  pr[0] = 1;
  pr[1] = mod / 2 + 1;
  for (int i = 2; i <= n; ++i) pr[i] = ((long long)pr[i - 1] * pr[1]) % mod;
  cout << solution() << endl;
}
