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XXWBBXBBXXBWXXWBWWBXWXXWWXXBXBWBWXWBBBWXXWXXWBWBBXWWBBWXXXBBWWXXXXBBBBBBWWBBWBWBXXWWXXBWXWWBB
 3 1
XBW
 4 1
XXXW
 100 20
WBBXWBBWWWXBXWWWWWBBBWWBWWBWWWWXWXXBWWBWXWBBXWBWBXWXWXWWBWWWBBXWWBXBBBWBXXWWBXXWWXWXWXBBBWXXWWBWBWXW
 4 1
XXWW
 20 1
XBBBWBXXBWXWWWBWWXXW
 2 1
WX
 3 1
XBX
 20 2
XXXBXWBBBBWXWWWXWWXB
 20 3
BWWWWWXBWXXXXBBWBBWX
 10 3
BXBWBWWWWX
 10 3
WWXBWXXWWW

0
 0
 0
 0
 0
 1
 10
 951778854
 135234318
 1
 0
 4
 0
 0
 0
 0
 28
 1
 817953325
 0
 0
 0
 4
 0
 1
 11
 1048576
 23240159
 126
 8
 469056403
 2
 7
 0
 3
 64
 0
 2
 128
 0
 2
 0

#include <bits/stdc++.h>
#pragma GCC optimize(1)
#pragma G++ optimize(1)
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#pragma GCC optimize(3)
#pragma G++ optimize(3)
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
using namespace std;
inline void rdl(long long &val) {
  long long x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0' or ch > '9') and ch != '-') ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' and ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  val = x * f;
}
inline void rdi(int &val) {
  int x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0' or ch > '9') and ch != '-') ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' and ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  val = x * f;
}
inline long long rdl() {
  long long x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0' or ch > '9') and ch != '-') ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' and ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline int rdi() {
  int x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0' or ch > '9') and ch != '-') ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' and ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void _write(int x) {
  write(x);
  putchar(' ');
}
inline void print(int x) {
  write(x);
  putchar('\n');
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void _write(long long x) {
  write(x);
  putchar(' ');
}
inline void print(long long x) {
  write(x);
  putchar('\n');
}
struct dsu {
  int par[200200];
  inline void init(int _n) {
    for (int i = 0; i < _n; ++i) par[i] = i;
  }
  inline int find(int now) {
    if (par[now] == now) return now;
    return par[now] = find(par[now]);
  }
  inline bool uni(int a, int b) {
    int Pa(find(a)), Pb(find(b));
    if (Pa == Pb) return false;
    par[Pa] = Pb;
    return true;
  }
};
const int mxn = 1e6 + 6;
int bsum[mxn], wsum[mxn], n, k;
string s;
long long lm[mxn], bf[mxn], rm[mxn], wf[mxn];
const long long md = 1000000007;
inline void dpl() {
  int i;
  bf[0] = 1;
  for (i = 1; i <= n; ++i) {
    if (i >= k and wsum[i] - wsum[i - k] == 0)
      if (i == k or s[i - k - 1] != 'B') lm[i] = bf[max(i - k - 1, 0)];
    long long t = bf[i - 1];
    if (s[i - 1] == 'X') t = t * 2 % md;
    t = (t - lm[i] + md) % md;
    bf[i] = t;
  }
}
inline void dpr() {
  int i;
  wf[n] = 1;
  for (i = n - 1; ~i; --i) {
    if (i <= n - k and bsum[i + k] - bsum[i] == 0)
      if (i == n - k or s[i + k] != 'W') rm[i] = wf[min(i + k + 1, n)];
    long long t = wf[i + 1];
    if (s[i] == 'X') t = (t * 2) % md;
    t = (t - rm[i] + md) % md;
    wf[i] = t;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int i;
  cin >> n >> k >> s;
  for (i = 0; i < n; ++i) bsum[i + 1] = bsum[i] + (bool)(s[i] == 'B');
  for (i = 0; i < n; ++i) wsum[i + 1] = wsum[i] + (bool)(s[i] == 'W');
  dpl();
  dpr();
  long long ans = 0, tw = 1;
  for (i = n - 1; ~i; --i) {
    if (s[i] == 'X') tw = tw * 2 % md;
    long long cw = (tw - wf[i] + md) % md;
    ans = (ans + lm[i] * cw) % md;
  }
  cout << ans << endl;
  return 0;
}
