func_code_string: #include <bits/stdc++.h>   using namespace std;   int N, K;   char s[1100000];   int cnt[1100000][3], tot[1100000];   int pb[1100000], pw[1100000];   bool can(int p, int f) {     if (p < K) return false;     if (f) {       if (p - pb[p - 1] - 1 < K) return false;       if (p > K && s[p - K - 1] ==  W ) return false;       return true;     } else {       if (p - pw[p - 1] - 1 < K) return false;       if (p > K && s[p - K - 1] ==  B ) return false;       return true;     }   }   int main() {     int b, w, i;     scanf( %d%d , &N, &K);     scanf( %s , s);     if (N < K * 2) {       puts( 0 );       return 0;     }     b = w = -1;     for (i = 0; i < N; i++) {       if (s[i] ==  B ) b = i;       if (s[i] ==  W ) w = i;       pb[i] = b;       pw[i] = w;     }     cnt[0][0] = 1;     tot[0] = 1;     for (i = 1; i <= N; i++) {       if (s[i - 1] ==  X )         tot[i] = tot[i - 1] * 2 % 1000000007;       else         tot[i] = tot[i - 1];       if (s[i - 1] ==  X )         cnt[i][2] = cnt[i - 1][2] * 2 % 1000000007;       else         cnt[i][2] = cnt[i - 1][2];       if (can(i, 1)) {         cnt[i][2] += cnt[max(i - K - 1, 0)][1];         cnt[i][2] %= 1000000007;         if (can(i - K, 0)) {           cnt[i][2] += cnt[max(i - K * 2 - 1, 0)][0];           cnt[i][2] %= 1000000007;         }       }       if (s[i - 1] ==  X )         cnt[i][0] = cnt[i - 1][0] * 2 % 1000000007;       else         cnt[i][0] = cnt[i - 1][0];       if (can(i, 0)) {         cnt[i][0] -= cnt[max(i - K - 1, 0)][0];         if (cnt[i][0] < 0) cnt[i][0] += 1000000007;       }       cnt[i][1] = tot[i];       cnt[i][1] -= cnt[i][0];       if (cnt[i][1] < 0) cnt[i][1] += 1000000007;       cnt[i][1] -= cnt[i][2];       if (cnt[i][1] < 0) cnt[i][1] += 1000000007;     }     printf( %d n , cnt[N][2]);     return 0;   }   