#include <bits/stdc++.h>
using namespace std;
struct Modint {
  int val;
  Modint(int a = 0) { val = a; }
  Modint& operator+=(Modint r) {
    val = (val + r.val) % 1000000007;
    return *this;
  }
  Modint& operator-=(Modint r) {
    val = (val + 1000000007 - r.val) % 1000000007;
    return *this;
  }
  Modint& operator*=(Modint r) {
    val = 1LL * val * r.val % 1000000007;
    return *this;
  }
  Modint operator+(Modint r) { return Modint(*this) += r; }
  Modint operator-(Modint r) { return Modint(*this) -= r; }
  Modint operator*(Modint r) { return Modint(*this) *= r; }
};
Modint dp[1000001][2][3], dpsum[1000001][2][3];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  string s;
  cin >> n >> k >> s;
  vector<int> last[2] = {vector<int>(n + 1, 0), vector<int>(n + 1, 0)};
  for (int i = 0; i < n; i++) {
    last[0][i + 1] = last[0][i];
    last[1][i + 1] = last[1][i];
    if (s[i] == 'W') last[0][i + 1] = i + 1;
    if (s[i] == 'B') last[1][i + 1] = i + 1;
  }
  dp[0][0][0] = 1;
  dp[0][1][0] = 1;
  for (int pos = 1; pos <= n; pos++) {
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 3; j++) {
        dpsum[pos][i][j] += dpsum[pos - 1][i][j] + dp[pos - 1][i][j];
        dp[pos][1 - i][j] += dpsum[pos][i][j] - dpsum[last[i][pos]][i][j];
      }
    if (last[1][pos] < pos - k + 1) {
      dp[pos][0][1] -= dpsum[pos - k + 1][1][1] - dpsum[last[1][pos]][1][1];
      dp[pos][0][2] += dpsum[pos - k + 1][1][1] - dpsum[last[1][pos]][1][1];
    }
    if (last[0][pos] < pos - k + 1) {
      dp[pos][1][0] -= dpsum[pos - k + 1][0][0] - dpsum[last[0][pos]][0][0];
      dp[pos][1][1] += dpsum[pos - k + 1][0][0] - dpsum[last[0][pos]][0][0];
    }
  }
  cout << (dp[n][0][2] + dp[n][1][2]).val << '\n';
  return 0;
}
