#include <bits/stdc++.h>
using namespace std;
int sumW[1000007], sumB[1000007];
char A[1000007];
int N, K, dp[1000007][2][2][2];
int countW(int i, int j) { return sumW[j] - sumW[i - 1]; }
int countB(int i, int j) { return sumB[j] - sumB[i - 1]; }
int mix(int i, int t1, int t2) {
  if (i == 0) return dp[i][0][t1][t2];
  return (dp[i][0][t1][t2] + dp[i][1][t1][t2]) % 1000000007;
}
int solve(void) {
  int i;
  dp[0][0][0][0] = dp[0][1][0][0] = 1;
  for (i = 1; i <= N; i++) {
    if (A[i] == 'X' || A[i] == 'B') {
      dp[i][0][1][0] += mix(i - 1, 1, 0), dp[i][0][1][0] %= 1000000007;
      if (i - K >= 0 && countW(i - K + 1, i - 1) == 0)
        dp[i][0][1][0] += dp[i - K][1][0][0], dp[i][0][1][0] %= 1000000007;
    }
    if (A[i] == 'X' || A[i] == 'W') {
      dp[i][1][1][0] += mix(i - 1, 1, 0), dp[i][1][1][0] %= 1000000007;
      if (i - K >= 0 && countB(i - K + 1, i - 1) == 0)
        dp[i][1][1][0] += (1000000007 - dp[i - K][0][1][0]),
            dp[i][1][1][0] %= 1000000007;
    }
    if (A[i] == 'X' || A[i] == 'B') {
      dp[i][0][0][0] += mix(i - 1, 0, 0), dp[i][0][0][0] %= 1000000007;
      if (i - K >= 0 && countW(i - K + 1, i - 1) == 0)
        dp[i][0][0][0] += (1000000007 - dp[i - K][1][0][0]),
            dp[i][0][0][0] %= 1000000007;
    }
    if (A[i] == 'X' || A[i] == 'W')
      dp[i][1][0][0] += mix(i - 1, 0, 0), dp[i][1][0][0] %= 1000000007;
    if (A[i] == 'X' || A[i] == 'B')
      dp[i][0][1][1] += mix(i - 1, 1, 1), dp[i][0][1][1] %= 1000000007;
    if (A[i] == 'X' || A[i] == 'W') {
      dp[i][1][1][1] += mix(i - 1, 1, 1), dp[i][1][1][1] %= 1000000007;
      if (i - K >= 0 && countB(i - K + 1, i - 1) == 0)
        dp[i][1][1][1] += dp[i - K][0][1][0], dp[i][1][1][1] %= 1000000007;
    }
  }
  return (dp[N][0][1][1] + dp[N][1][1][1]) % 1000000007;
}
int main(void) {
  scanf("%d %d\n", &N, &K);
  scanf("%s\n", A + 1);
  int i;
  for (i = 1; i <= N; i++)
    sumB[i] = sumB[i - 1] + (A[i] == 'B'),
    sumW[i] = sumW[i - 1] + (A[i] == 'W');
  printf("%d\n", solve());
  return 0;
}
