#include <bits/stdc++.h>
using namespace std;
char buf[1 << 21], *p1 = buf, *p2 = buf;
template <class T>
void read(T &x) {
  x = 0;
  int c = getchar();
  int flag = 0;
  while (c < '0' || c > '9') flag |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
template <class T>
T _max(T a, T b) {
  return b < a ? a : b;
}
template <class T>
T _min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
bool checkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
bool checkmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
const int N = 1000005, mod = 1000000000 + 7;
int Add(int a, int b) {
  a += b;
  return a >= mod ? a - mod : a;
}
int Sub(int a, int b) {
  a -= b;
  return a < 0 ? a + mod : a;
}
int Mul(int a, int b) { return (long long)a * b % mod; }
void add(int &a, int b) {
  a += b;
  (a >= mod) && (a -= mod);
}
void sub(int &a, int b) {
  a -= b;
  (a < 0) && (a += mod);
}
void mul(int &a, int b) { a = (long long)a * b % mod; }
char s[N];
int n, k;
int sw[N], sb[N];
int no_w[N], no_b[N], w[N], b[N];
void init() {
  read(n);
  read(k);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; ++i) {
    sw[i] = sw[i - 1] + (s[i] == 'W');
    sb[i] = sb[i - 1] + (s[i] == 'B');
  }
}
void solve() {
  no_b[0] = 1;
  for (int i = 1; i <= n; ++i) {
    if (i >= k && sw[i] - sw[i - k] == 0) {
      if (i == k)
        b[i] = 1;
      else if (s[i - k] != 'B')
        b[i] = no_b[i - k - 1];
    }
    no_b[i] = Sub(no_b[i - 1], b[i]);
    if (s[i] == 'X') add(no_b[i], no_b[i - 1]);
  }
  no_w[n + 1] = 1;
  for (int i = n; i >= 1; --i) {
    if (i + k - 1 <= n && sb[i + k - 1] - sb[i - 1] == 0) {
      if (i == n - k + 1)
        w[i] = 1;
      else if (s[i + k] != 'W')
        w[i] = no_w[i + k + 1];
    }
    no_w[i] = Sub(no_w[i + 1], w[i]);
    if (s[i] == 'X') add(no_w[i], no_w[i + 1]);
  }
  int total = 1, ans = 0;
  for (int i = n; i >= 1; --i) {
    if (s[i] == 'X') mul(total, 2);
    int ways = Sub(total, no_w[i]);
    add(ans, Mul(ways, b[i - 1]));
  }
  printf("%d\n", ans);
}
int main() {
  init();
  solve();
  return 0;
}
