#include <bits/stdc++.h>
int n, k, now;
char a[1000005];
long long b[1000005];
long long W[1000005];
long long B[1000005];
long long rst;
int main() {
  scanf("%d%d%s", &n, &k, &a[1]);
  int i;
  b[0] = 1;
  for (i = 1; i <= n; i++) {
    if (a[i] == 'X' || a[i] == 'B')
      now++;
    else
      now = 0;
    if (a[i] == 'X')
      b[i] = (b[i - 1] * 2) % 1000000007;
    else
      b[i] = b[i - 1];
    if (now < k) continue;
    if (i == k) {
      b[i] = (b[i] - b[i - k] + 1000000007) % 1000000007;
      B[i] = b[i - k];
    } else if (i > k && (a[i - k] == 'X' || a[i - k] == 'W')) {
      b[i] = (b[i] - b[i - k - 1] + 1000000007) % 1000000007;
      B[i] = b[i - k - 1];
    }
  }
  b[n + 1] = 1;
  now = 0;
  for (i = n; i >= 1; i--) {
    if (a[i] == 'W' || a[i] == 'X')
      now++;
    else
      now = 0;
    if (a[i] == 'X')
      b[i] = (b[i + 1] * 2) % 1000000007;
    else
      b[i] = b[i + 1];
    if (a[i] == 'X')
      W[i] = (W[i + 1] * 2) % 1000000007;
    else
      W[i] = W[i + 1];
    if (now < k) continue;
    if (i + k - 1 == n) {
      b[i] = (b[i] - b[i + k] + 1000000007) % 1000000007;
      W[i] = (W[i] + b[i + k]) % 1000000007;
    } else if (i + k - 1 < n && (a[i + k] == 'X' || a[i + k] == 'B')) {
      b[i] = (b[i] - b[i + k + 1] + 1000000007) % 1000000007;
      W[i] = (W[i] + b[i + k + 1]) % 1000000007;
    }
  }
  for (i = 1; i <= n; i++) {
    rst = (rst + B[i] * W[i + 1]) % 1000000007;
  }
  printf("%I64d", rst);
}
