#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:255000000")
bool firstout = 1;
template <class T>
T &minn(T &a, T b) {
  if (b < a) a = b;
  return a;
}
template <class T>
T &maxx(T &a, T b) {
  if (a < b) a = b;
  return a;
}
int &madd(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
int &msub(int &a, int b) {
  a -= b;
  if (a < 0) a += 1000000007;
  return a;
}
int &mmult(int &a, int b) { return a = (long long)a * b % 1000000007; }
int mdiv(long long a, long long b, long long m) {
  a = (a % m + m) % m;
  b = (b % m + m) % m;
  if (a % b == 0) return a / b;
  return (a + m * mdiv(-a, m, b)) / b;
}
int n, m;
char S[1012345];
int T[1012345], TT[1012345];
int A[1012345], B[1012345];
void calc(char c, int *R) {
  T[0] = TT[0] = 1;
  int i;
  int l = 0;
  for (i = (0); i < (n); ++i) {
    T[i + 1] = T[i];
    TT[i + 1] = T[i];
    if (S[i] == c) TT[i + 1] = 0;
    if (S[i] == 'X') madd(T[i + 1], T[i]);
    if (S[i] == c || S[i] == 'X')
      ++l;
    else
      l = 0;
    if (l >= m) msub(T[i + 1], TT[i + 1 - m]);
    if (l >= m)
      R[i] = TT[i - m + 1];
    else
      R[i] = 0;
  }
}
int main() {
  int i, j, k;
  char c;
  int a, d;
  int ts;
  for (ts = 1; scanf("%"
                     "d",
                     &(n)) > 0;
       ++ts) {
    scanf(
        "%"
        "d",
        &(m));
    scanf(
        "%"
        "s",
        &(S));
    calc('B', A);
    reverse(S, S + n);
    calc('W', B);
    reverse(B, B + n);
    reverse(S, S + n);
    int res = 0;
    int r = 0;
    for (i = (n)-1; i >= (1); --i) {
      if (S[i] == 'X') madd(r, r);
      madd(r, B[i]);
      madd(res, (long long)r * A[i - 1] % 1000000007);
    }
    printf(
        "%"
        "d",
        (res));
    printf("\n"), firstout = 1;
  }
  return 0;
}
