#include <bits/stdc++.h>
using namespace std;
int n, k, B, W, dp[1000005][6], ans;
char s[1000005];
int f(long long x) { return (int)((x % 1000000007 + 1000000007) % 1000000007); }
int main() {
  s[0] = '!';
  scanf("%d%d%s", &n, &k, s + 1);
  dp[0][0] = 0;
  dp[0][1] = 1;
  dp[0][2] = dp[0][3] = dp[0][4] = dp[0][5] = 0;
  B = W = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == 'B') B = i;
    if (s[i] == 'W') W = i;
    if (W <= i - k)
      dp[i][2] = dp[i - k][1];
    else
      dp[i][2] = 0;
    if (s[i] == 'B' || s[i] == 'X')
      dp[i][0] = f(dp[i - 1][0] + dp[i - 1][1] - dp[i][2]);
    else
      dp[i][0] = 0;
    if (s[i] == 'W' || s[i] == 'X')
      dp[i][1] = f(dp[i - 1][0] + dp[i - 1][1]);
    else
      dp[i][1] = 0;
    if (B <= i - k)
      dp[i][5] = dp[i - k][3];
    else
      dp[i][5] = 0;
    if (s[i] == 'B' || s[i] == 'X')
      dp[i][3] = f(dp[i - 1][3] + dp[i - 1][4] + (long long)dp[i][2]);
    else
      dp[i][3] = 0;
    if (s[i] == 'W' || s[i] == 'X')
      dp[i][4] = f(dp[i - 1][3] + dp[i - 1][4] - dp[i][5]);
    else
      dp[i][4] = 0;
  }
  ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == 'X')
      ans = f(ans + ans + (long long)dp[i][5]);
    else
      ans = f(ans + dp[i][5]);
  }
  printf("%d\n", ans);
  return 0;
}
