#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
const int MOD = 1000000007;
int sum[maxn][2];
long long b[maxn][3], w[maxn][3];
char s[maxn];
int k;
void init() {
  int l = strlen(s);
  for (int i = 0; i < l; i++) {
    if (i == 0) {
      sum[i][0] = (s[i] != 'W');
      sum[i][1] = (s[i] != 'B');
    } else {
      sum[i][0] = sum[i - 1][0] + (s[i] != 'W');
      sum[i][1] = sum[i - 1][1] + (s[i] != 'B');
    }
  }
}
bool check(int i, int j, int z) {
  if (i == 1)
    return (sum[j - 1][z] == k);
  else
    return ((sum[j - 1][z] - sum[i - 2][z]) == k);
}
int main() {
  int n;
  scanf("%d %d", &n, &k);
  scanf("%s", s);
  init();
  b[0][0] = w[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    if (i == 1) {
      if (s[i - 1] != 'W') b[i][k == 1] = 1;
      if (s[i - 1] != 'B') w[i][0] = 1;
    } else {
      if (s[i - 1] != 'W') {
        if (i < k)
          b[i][0] = (b[i - 1][0] + w[i - 1][0]) % MOD;
        else
          b[i][0] = (b[i - 1][0] + w[i - 1][0] -
                     w[i - k][0] * check(i - k + 1, i, 0)) %
                    MOD;
        if (i < k)
          b[i][1] = (b[i - 1][1] + w[i - 1][1]) % MOD;
        else
          b[i][1] = (b[i - 1][1] + w[i - 1][1] +
                     w[i - k][0] * check(i - k + 1, i, 0)) %
                    MOD;
        b[i][2] = (b[i - 1][2] + w[i - 1][2]) % MOD;
      }
      if (s[i - 1] != 'B') {
        w[i][0] = (w[i - 1][0] + b[i - 1][0]) % MOD;
        if (i < k)
          w[i][1] = (w[i - 1][1] + b[i - 1][1]) % MOD;
        else
          w[i][1] = (w[i - 1][1] + b[i - 1][1] -
                     b[i - k][1] * check(i - k + 1, i, 1)) %
                    MOD;
        if (i < k)
          w[i][2] = (w[i - 1][2] + b[i - 1][2]) % MOD;
        else
          w[i][2] = (w[i - 1][2] + b[i - 1][2] +
                     b[i - k][1] * check(i - k + 1, i, 1)) %
                    MOD;
      }
      for (int j = 0; j < 3; j++) {
        b[i][j] = (b[i][j] + MOD) % MOD;
        w[i][j] = (w[i][j] + MOD) % MOD;
      }
    }
  }
  printf("%I64d\n", (b[n][2] + w[n][2]) % MOD);
  return 0;
}
