#include <bits/stdc++.h>
using namespace std;
int f[1000005][2];
int g[1000005][2];
int mark[1000005];
char st[1000005];
int ls1[1000005];
int rs1[1000005];
int ls2[1000005];
int rs2[1000005];
int ld[1000005];
int rd[1000005];
int lc[1000005];
int rc[1000005];
int n, k;
void pre() {
  int i;
  for (i = 1; i <= n; ++i)
    if (st[i] == 'X') mark[i] = 1;
  ld[0] = rd[0] = 1;
  for (i = 1; i <= n; ++i)
    if (mark[i])
      ld[i] = 500000004LL * ld[i - 1] % 1000000007;
    else
      ld[i] = ld[i - 1];
  for (i = rd[0] = 1; i <= n; ++i)
    if (mark[i])
      rd[i] = 2 * rd[i - 1] % 1000000007;
    else
      rd[i] = rd[i - 1];
}
void dpl() {
  int i;
  for (i = 1; i <= n; ++i)
    if (st[i] != 'W')
      lc[i] = lc[i - 1] + 1;
    else
      lc[i] = 0;
  if (st[1] != 'W') f[1][1] = 1;
  if (st[1] != 'B') f[1][0] = 1;
  if (k == 1) f[1][1] = 0;
  f[0][0] = 1;
  for (i = 2; i <= n; ++i) {
    if (st[i] != 'B') {
      f[i][0] = f[i - 1][0] + f[i - 1][1];
      f[i][0] %= 1000000007;
    }
    if (st[i] != 'W') {
      f[i][1] = f[i - 1][0] + f[i - 1][1];
      f[i][1] %= 1000000007;
      if (i >= k && lc[i] >= k) f[i][1] -= f[i - k][0];
      f[i][1] = (f[i][1] + 1000000007) % 1000000007;
    }
  }
  for (i = k; i <= n; ++i)
    if (lc[i] >= k) ls1[i] = f[i - k][0];
  for (i = 1; i <= n; ++i) ls2[i] = (long long)ls1[i] * ld[i] % 1000000007;
}
void dpr() {
  int i;
  for (i = n; i > 0; --i)
    if (st[i] != 'B')
      rc[i] = rc[i + 1] + 1;
    else
      rc[i] = 0;
  if (st[n] != 'W') g[n][1] = 1;
  if (st[n] != 'B') g[n][0] = 1;
  if (k == 1) g[n][0] = 0;
  g[n + 1][1] = 1;
  for (i = n - 1; i > 0; --i) {
    if (st[i] != 'W') {
      g[i][1] = g[i + 1][0] + g[i + 1][1];
      g[i][1] %= 1000000007;
    }
    if (st[i] != 'B') {
      g[i][0] = g[i + 1][0] + g[i + 1][1];
      g[i][0] %= 1000000007;
      if (i <= n - k + 1 && rc[i] >= k) g[i][0] -= g[i + k][1];
      g[i][0] = (g[i][0] + 1000000007) % 1000000007;
    }
  }
  for (i = n - k + 1; i > 0; --i)
    if (rc[i] >= k) rs1[i] = g[i + k][1];
  for (i = 1; i <= n; ++i) rs2[i] = (long long)rs1[i] * rd[i - 1] % 1000000007;
}
int dp() {
  int i;
  long long ans, p;
  p = ans = 0;
  for (i = 1; i <= n; ++i) {
    p += rs2[i];
    p %= 1000000007;
  };
  for (i = 1; i <= n; ++i) {
    p -= rs2[i];
    if (p < 0) p += 1000000007;
    ans += ls2[i] * p;
    ans %= 1000000007;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &k);
  scanf("%s\n", st + 1);
  pre();
  dpl(), dpr();
  printf("%d\n", dp());
  return 0;
}
