#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long p2[1000010], inv[1000010], inv2;
int preB[1000010], preW[1000010], preX[1000010];
long long dp1[1000010], sum1[1000010], dp2[1000010], sum2[1000010],
    sum3[1000010];
char s[1000010];
long long pow1(long long a, long long b) {
  if (b == 0) return 1;
  long long ret = pow1(a, b / 2);
  ret = (ret * ret) % 1000000007;
  if (b & 1) ret = (a * ret) % 1000000007;
  return ret;
}
int getW(int l, int r) {
  if (l > r) return 0;
  return preW[r] - preW[l - 1];
}
int getB(int l, int r) {
  if (l > r) return 0;
  return preB[r] - preB[l - 1];
}
int getX(int l, int r) {
  if (l > r) return 0;
  return preX[r] - preX[l - 1];
}
int main() {
  int i;
  p2[0] = 1;
  for (i = 1; i < 1000010; ++i) p2[i] = p2[i - 1] * 2 % 1000000007;
  inv2 = pow1(2, 1000000007 - 2);
  inv[0] = 1;
  for (i = 1; i < 1000010; ++i) inv[i] = inv[i - 1] * inv2 % 1000000007;
  int n, k;
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%s", s);
  preB[0] = preW[0] = preX[0] = 0;
  for (i = 1; i <= n; ++i) {
    preB[i] = preB[i - 1];
    preW[i] = preW[i - 1];
    preX[i] = preX[i - 1];
    if (s[i - 1] == 'B')
      preB[i]++;
    else if (s[i - 1] == 'W')
      preW[i]++;
    else
      preX[i]++;
  }
  for (i = n + 1; i < 1000010; ++i) {
    preB[i] = preB[i - 1];
    preW[i] = preW[i - 1];
    preX[i] = preX[i - 1];
  }
  memset(dp1, 0, sizeof(dp1));
  memset(dp2, 0, sizeof(dp2));
  memset(sum1, 0, sizeof(sum1));
  memset(sum2, 0, sizeof(sum2));
  memset(sum3, 0, sizeof(sum3));
  if (getB(n - k + 1, n))
    dp1[n - k + 1] = 0;
  else
    dp1[n - k + 1] = p2[getX(1, n - k)];
  sum1[n - k + 1] = dp1[n - k + 1];
  for (i = n - k; i >= 1; --i) {
    if (getB(i, i + k - 1) || s[i + k - 1] == 'W')
      dp1[i] = 0;
    else {
      dp1[i] = p2[getX(1, i - 1) + getX(i + k + 1, n)];
      dp1[i] = (dp1[i] - sum1[i + k + 1] * inv[getX(i, i + k)] % 1000000007 +
                1000000007) %
               1000000007;
    }
    sum1[i] = (sum1[i + 1] + dp1[i]) % 1000000007;
  }
  for (i = n - k; i >= 1; --i) {
    if (getW(i, i + k - 1))
      dp2[i] = 0;
    else {
      dp2[i] = sum1[i + k] * inv[getX(i, i + k - 1)] % 1000000007;
      long long val = (sum3[i + 1] - sum3[i + k] + 1000000007) *
                      p2[getX(1, i - 1)] % 1000000007;
      val = (val + sum2[i + k] * inv[getX(i, i + k - 1)] % 1000000007) %
            1000000007;
      dp2[i] = (dp2[i] - val + 1000000007) % 1000000007;
    }
    sum2[i] = (sum2[i + 1] + dp2[i]) % 1000000007;
    sum3[i] =
        (sum3[i + 1] + dp2[i] * inv[getX(1, i - 1)] % 1000000007) % 1000000007;
  }
  printf("%lld\n", sum2[1]);
}
