#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int MOD = 1000000007;
char s[1000007];
int n, k;
int dp[1000007][4];
int main() {
  scanf("%d%d%s", &n, &k, s);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'X')
      s[i] = 2;
    else if (s[i] == 'B')
      s[i] = 0;
    else
      s[i] = 1;
  }
  dp[0][0] = 1;
  int count[3] = {0};
  for (int i = 1; i <= n; ++i) {
    ++count[s[i - 1]];
    dp[i][2] = dp[i - 1][2] * (s[i - 1] == 2 ? 2 : 1) % MOD;
    dp[i][1] = dp[i - 1][1] * (s[i - 1] == 2 ? 2 : 1) % MOD;
    if (i >= 2 * k) {
      if (count[1] + count[2] == k) {
        if (s[i - 1 - k] != 1) {
          dp[i][1] -= (dp[i - k - 1][1] + dp[i - k][3]) % MOD;
          dp[i][1] %= MOD;
          dp[i][2] += (dp[i - k - 1][1] + dp[i - k][3]) % MOD;
          dp[i][2] %= MOD;
        }
      }
    }
    dp[i][0] = dp[i - 1][0] * (s[i - 1] == 2 ? 2 : 1) % MOD;
    if (i >= k) {
      if (count[0] + count[2] == k) {
        if (i == k) {
          dp[i][0] -= 1;
          dp[i][0] %= MOD;
          dp[i][1] += 1;
          dp[i][1] %= MOD;
          dp[i][3] = 1;
        } else if (s[i - 1 - k] != 0) {
          dp[i][0] -= dp[i - k - 1][0];
          dp[i][0] %= MOD;
          dp[i][1] += dp[i - k - 1][0];
          dp[i][1] %= MOD;
          dp[i][3] = dp[i - k - 1][0];
        }
      }
    }
    if (i >= k) --count[s[i - k]];
  }
  cout << (dp[n][2] + MOD) % MOD << endl;
  return 0;
}
