#include <bits/stdc++.h>
long long dslr[1000050], dsrl[1000050], llsw[1000050], llsb[1000050],
    dsw[1000050], dsb[1000050];
int main() {
  long long n, k, i;
  scanf("%I64d%I64d", &n, &k);
  char s[n + 1];
  scanf("%s", s);
  if (n < 2 * k) {
    printf("0");
    return 0;
  }
  dslr[0] = (s[0] == 'X') ? 2 : 1;
  for (i = 1; i < n; i++)
    dslr[i] = (s[i] == 'X') ? (dslr[i - 1] * 2) % 1000000007 : dslr[i - 1];
  dsrl[n - 1] = (s[n - 1] == 'X') ? 2 : 1;
  for (i = n - 2; i >= 0; i--)
    dsrl[i] = (s[i] == 'X') ? (dsrl[i + 1] * 2) % 1000000007 : dsrl[i + 1];
  llsw[n - 1] = (s[n - 1] == 'B') ? 0 : 1;
  for (i = n - 2; i >= 0; i--) llsw[i] = (s[i] == 'B') ? 0 : (llsw[i + 1] + 1);
  llsb[0] = (s[0] == 'W') ? 0 : 1;
  for (i = 1; i < n; i++) llsb[i] = (s[i] == 'W') ? 0 : (llsb[i - 1] + 1);
  dsw[n - k] = (llsw[n - k] == k);
  for (i = n - k - 1; i >= 0; i--) {
    if (s[i] == 'W') {
      dsw[i] = dsw[i + 1];
      if (llsw[i] >= k) {
        if (s[i + k] != 'W')
          dsw[i] = (dsw[i] + (i + k + 1 == n) +
                    (i + k + 1 != n) *
                        ((dsrl[i + k + 1] - dsw[i + k + 1] + 1000000007)) %
                        1000000007) %
                   1000000007;
      }
    } else if (s[i] == 'B')
      dsw[i] = dsw[i + 1];
    else {
      dsw[i] = (2 * dsw[i + 1]) % 1000000007;
      if (llsw[i] >= k) {
        if (s[i + k] != 'W')
          dsw[i] = (dsw[i] + (i + k + 1 == n) +
                    (i + k + 1 != n) *
                        ((dsrl[i + k + 1] - dsw[i + k + 1] + 1000000007) %
                         1000000007)) %
                   1000000007;
      }
    }
  }
  dsb[k - 1] = (llsb[k - 1] == k);
  for (i = k; i < n; i++) {
    if (s[i] == 'B') {
      dsb[i] = dsb[i - 1];
      if (llsb[i] >= k) {
        if (s[i - k] != 'B')
          dsb[i] = (dsb[i] + (i - k - 1 == -1) +
                    (i - k - 1 != -1) *
                        ((dslr[i - k - 1] - dsb[i - k - 1] + 1000000007)) %
                        1000000007) %
                   1000000007;
      }
    } else if (s[i] == 'W')
      dsb[i] = dsb[i - 1];
    else {
      dsb[i] = (2 * dsb[i - 1]) % 1000000007;
      if (llsb[i] >= k) {
        if (s[i - k] != 'B')
          dsb[i] = (dsb[i] + (i - k - 1 == -1) +
                    (i - k - 1 != -1) *
                        ((dslr[i - k - 1] - dsb[i - k - 1] + 1000000007) %
                         1000000007)) %
                   1000000007;
      }
    }
  }
  long long ans = 0;
  if (llsb[k - 1] == k) ans = dsw[k];
  for (i = k; i < n - 1; i++) {
    if (llsb[i] >= k) {
      if (s[i - k] != 'B')
        ans = ((ans + ((i - k - 1 == -1) +
                       (i - k - 1 != -1) *
                           ((dslr[i - k - 1] - dsb[i - k - 1] + 1000000007) %
                            1000000007)) *
                          dsw[i + 1]) %
               1000000007) %
              1000000007;
    }
  }
  printf("%I64d", ans);
  return 0;
}
