#include <bits/stdc++.h>
using namespace std;
long long ans, n, k, g[1000050], f[1000050], po[1000050], t1[1000050],
    t2[1000050], sum[1000050];
char c[1000050];
int main() {
  cin >> n >> k;
  scanf("%s", c + 1);
  po[0] = 1;
  int s = 0;
  for (int i = 1; i <= n; i++) {
    if (c[i] == 'W')
      s = 0;
    else
      s++;
    if (s >= k)
      f[i] =
          ((po[i - k] - t1[i - k] + 1000000007) % 1000000007 -
           (sum[i - 1] - sum[i - k] + 1000000007) % 1000000007 + 1000000007) %
          1000000007;
    if (c[i] == 'X')
      po[i] = (po[i - 1] * 2) % 1000000007;
    else
      po[i] = po[i - 1];
    if (c[i] == 'X')
      t1[i] = (t1[i - 1] * 2 + f[i]) % 1000000007;
    else
      t1[i] = (t1[i - 1] + f[i]) % 1000000007;
    sum[i] = (sum[i - 1] + f[i]) % 1000000007;
  }
  po[n + 1] = 1, s = 0;
  for (int i = n; i >= 1; i--) {
    if (c[i] == 'B')
      s = 0;
    else
      s++;
    if (s >= k)
      g[i] =
          ((po[i + k] - t2[i + k] + 1000000007) % 1000000007 -
           (sum[i + 1] - sum[i + k] + 1000000007) % 1000000007 + 1000000007) %
          1000000007;
    if (c[i] == 'X')
      po[i] = (po[i + 1] * 2) % 1000000007;
    else
      po[i] = po[i + 1];
    if (c[i] == 'X')
      t2[i] = (t2[i + 1] * 2 + g[i]) % 1000000007;
    else
      t2[i] = (t2[i + 1] + g[i]) % 1000000007;
    sum[i] = (sum[i + 1] + g[i]) % 1000000007;
  }
  for (int i = 1; i <= n; i++) ans = (ans + f[i] * t2[i + 1]) % 1000000007;
  cout << ans;
  return 0;
}
