#include <bits/stdc++.h>
using namespace std;
int ch = 0;
inline void read(int &a) {
  bool f = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = 1;
    ch = getchar();
  }
  a = 0;
  while (ch >= '0' && ch <= '9') {
    a = a * 10 + ch - '0';
    ch = getchar();
  }
  if (f) a = -a;
}
int n, K, sum[1000005][3];
char s[1000005];
void init() {
  read(n);
  read(K);
  scanf("%s", s + 1);
  s[++n] = 'X';
  for (int i = 1; i <= n; i++) s[i] = (s[i] == 'X') ? 0 : (s[i] == 'B' ? 1 : 2);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) sum[i][j] = sum[i - 1][j];
    sum[i][(int)s[i]]++;
  }
}
int dp[1000005][3][2];
void work() {
  dp[0][0][1] = 1;
  for (int i = 1; i <= n; i++) {
    if (s[i] != 2)
      for (int j = 0; j < 3; j++)
        dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1]) % 1000000007;
    if (s[i] != 1)
      for (int j = 0; j < 3; j++)
        dp[i][j][1] = (dp[i - 1][j][0] + dp[i - 1][j][1]) % 1000000007;
    if (i < K) continue;
    for (int j = 0; j < 2; j++) {
      if (s[i] != (2 - j) && sum[i][2 - j] == sum[i - K][2 - j]) {
        dp[i][j + 1][j] = (dp[i][j + 1][j] + dp[i - K][j][j ^ 1]) % 1000000007;
        dp[i][j][j] = (dp[i][j][j] - dp[i - K][j][j ^ 1]) % 1000000007;
      }
    }
  }
  printf("%d\n", ((dp[n][2][0] % 1000000007) + 1000000007) % 1000000007);
}
int main() {
  init();
  work();
  return 0;
}
