#include <bits/stdc++.h>
using namespace std;
const int N = 1110000;
const double eps = 1e-9;
const int oo = 0x7f7f7f7f;
const int mo = 1000000007;
int n, k, bc[N], wc[N], tt[N], f[N][2], g[N][2], fs[N][2], gs[N][2], f2[N],
    g2[N], gof[N], gog[N];
char s[N];
int c2i(char c) { return (c != 'W') + (c != 'B'); }
int main() {
  scanf("%d%d", &n, &k);
  scanf("%s", s + 1);
  bc[0] = wc[0] = 0;
  tt[0] = 1;
  for (int i = 1; i <= n; ++i) {
    bc[i] = bc[i - 1] + (s[i] == 'B');
    wc[i] = wc[i - 1] + (s[i] == 'W');
  }
  gof[1] = (k == 1) ? 1 : 0;
  for (int i = 2; i <= n; ++i) {
    gof[i] = s[i] == 'W' ? i - 1 : gof[i - 1];
    if (i - gof[i] >= k) {
      gof[i] = i - k + 1;
    }
  }
  gog[n] = (k == 1) ? n : n + 1;
  for (int i = n - 1; i >= 1; --i) {
    gog[i] = s[i] == 'B' ? i + 1 : gog[i + 1];
    if (gog[i] - i >= k) {
      gog[i] = i + k - 1;
    }
  }
  memset(f, 0, sizeof(f));
  memset(g, 0, sizeof(g));
  memset(fs, 0, sizeof(fs));
  memset(gs, 0, sizeof(gs));
  memset(f2, 0, sizeof(f2));
  memset(g2, 0, sizeof(g2));
  for (int i = 1; i <= n; ++i) {
    if (i == 1) {
      if (k > 1) {
        f[i][0] = (s[i] != 'W');
      }
      f[i][1] = (s[i] != 'B');
    } else if (i < k) {
      f[i][0] = (s[i] != 'W') * (f[i - 1][0] + f[i - 1][1]) % mo;
      f[i][1] = (s[i] != 'B') * (f[i - 1][0] + f[i - 1][1]) % mo;
    } else {
      f[i][0] = (s[i] != 'W') * ((fs[i - 1][1] - fs[gof[i - 1]][1]) % mo) % mo;
      f[i][1] = (s[i] != 'B') * (f[i - 1][0] + f[i - 1][1]) % mo;
    }
    fs[i][0] = (fs[i - 1][0] + f[i][0]) % mo;
    fs[i][1] = (fs[i - 1][1] + f[i][1]) % mo;
  }
  if (wc[k] == 0) {
    f2[k] = 1;
  }
  for (int i = k + 1; i <= n; ++i)
    if (wc[i] == wc[i - k]) {
      f2[i] = f[i - k][1];
    }
  for (int i = n; i >= 1; --i) {
    if (i == n) {
      g[i][0] = (s[i] != 'W');
      if (k > 1) {
        g[i][1] = (s[i] != 'B');
      }
    } else if (n - i + 1 < k) {
      g[i][0] = (s[i] != 'W') * (g[i + 1][0] + g[i + 1][1]) % mo;
      g[i][1] = (s[i] != 'B') * (g[i + 1][0] + g[i + 1][1]) % mo;
    } else {
      g[i][0] = (s[i] != 'W') * (g[i + 1][0] + g[i + 1][1]) % mo;
      g[i][1] = (s[i] != 'B') * ((gs[i + 1][0] - gs[gog[i + 1]][0]) % mo) % mo;
    }
    gs[i][0] = (gs[i + 1][0] + g[i][0]) % mo;
    gs[i][1] = (gs[i + 1][1] + g[i][1]) % mo;
  }
  if (bc[n] - bc[n - k] == 0) {
    g2[n - k + 1] = 1;
  }
  for (int i = n - k; i >= 1; --i)
    if (bc[i - 1] == bc[i + k - 1]) {
      g2[i] = g[i + k][0];
    }
  int temp = f2[k], ans = 0;
  for (int i = k + 1; i + k - 1 <= n; ++i) {
    ans = (ans + (long long)g2[i] * temp) % mo;
    temp = ((temp * c2i(s[i]) % mo) + f2[i]) % mo;
  }
  printf("%d\n", (ans + mo) % mo);
  return 0;
}
