#include <bits/stdc++.h>
using namespace std;
int N, K;
char str[1000010];
long long dp[1000010][2], fdp[1000010][2], f[1000010][2], sdp[1000010],
    waysp[1000010], wayss[1000010];
int bsums[1000010], wsums[1000010];
int isblack(int x) {
  if (x < K or x > N) return 0;
  int s = wsums[x] - wsums[x - K];
  if (s)
    return 0;
  else
    return 1;
}
int iswhite(int x) {
  if (x < K or x > N) return 0;
  int s = bsums[x] - bsums[x - K];
  if (s)
    return 0;
  else
    return 1;
}
int flagb(int x) {
  if (x <= 0 or x > N) return 1;
  if (str[x - 1] == 'W')
    return 0;
  else
    return 1;
}
int flagw(int x) {
  if (x <= 0 or x > N) return 1;
  if (str[x - 1] == 'B')
    return 0;
  else
    return 1;
}
int pos(int x) {
  if (str[x - 1] == 'X')
    return 2;
  else
    return 1;
}
long long norm(long long x) {
  return ((x % 1000000007) + 1000000007) % 1000000007;
}
long long dps(int x) {
  if (x < 0) return 0;
  long long ret = dp[x][0] + dp[x][1];
  if (ret >= 1000000007) ret -= 1000000007;
  return ret;
}
long long fdps(int x) {
  if (x < 0) return 0;
  long long ret = fdp[x][0] + fdp[x][1];
  if (ret >= 1000000007) ret -= 1000000007;
  return ret;
}
long long fs(int x) {
  if (x < 0) return 0;
  long long ret = f[x][0] + f[x][1];
  if (ret >= 1000000007) ret -= 1000000007;
  return ret;
}
long long sdps(int x) {
  if (x < 0) return 1;
  long long ret = sdp[x];
  return ret;
}
long long ways(int x) {
  if (x > N)
    return 1;
  else
    return wayss[x];
}
inline void go(void) {
  for (int i = 1; i <= N; i++) {
    wsums[i] = wsums[i - 1];
    bsums[i] = bsums[i - 1];
    if (str[i - 1] == 'W')
      wsums[i]++;
    else if (str[i - 1] == 'B')
      bsums[i]++;
  }
  waysp[0] = 1;
  sdp[0] = 1;
  for (int i = 1; i <= N; i++) {
    dp[i][1] = dps(i - 1) * pos(i) - iswhite(i) * fs(i - K);
    dp[i][0] = flagw(i - K) * isblack(i) * sdps(i - K - 1);
    dp[i][1] = norm(dp[i][1]);
    dp[i][0] = norm(dp[i][0]);
    f[i][0] = dp[i][0];
    f[i][1] = dps(i - 1) * flagb(i);
    fdp[i][0] = sdps(i - K - 1) * flagw(i - K) * isblack(i);
    fdp[i][1] = fdps(i - 1) * pos(i);
    fdp[i][0] = norm(fdp[i][0]);
    fdp[i][1] = norm(fdp[i][1]);
    waysp[i] = norm(waysp[i - 1] * pos(i));
    sdp[i] = norm(waysp[i] - fdps(i));
  }
  wayss[N + 1] = 1;
  for (int i = N; i >= 1; i--) {
    wayss[i] = norm(wayss[i + 1] * pos(i));
  }
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    long long foo = (fs(i) * iswhite(i + K) * ways(i + K + 1)) % 1000000007;
    ans = ans + foo;
    if (ans >= 1000000007) ans -= 1000000007;
  }
  cout << ans;
}
inline void ReadInput(void) {
  scanf("%d", &N);
  scanf("%d", &K);
  scanf("%s", str);
}
inline void solve(void) { go(); }
inline void Refresh(void) {}
int main() {
  ReadInput();
  solve();
  return 0;
}
