func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, U b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, U b) {     if (a < b) a = b;   }   template <class T>   inline void gn(T &first) {     char c, sg = 0;     while (c = getchar(), (c >  9  || c <  0 ) && c !=  - )       ;     for ((c ==  -  ? sg = 1, c = getchar() : 0), first = 0; c >=  0  && c <=  9 ;          c = getchar())       first = (first << 1) + (first << 3) + c -  0 ;     if (sg) first = -first;   }   template <class T>   inline void print(T first) {     if (first < 0) {       putchar( - );       return print(-first);     }     if (first < 10) {       putchar( 0  + first);       return;     }     print(first / 10);     putchar(first % 10 +  0 );   }   int power(int a, int b, int m, int ans = 1) {     for (; b; b >>= 1, a = 1LL * a * a % m)       if (b & 1) ans = 1LL * ans * a % m;     return ans;   }   char s[100011];   pair<int, int> dp[100011];   int cnt[100011], mx[100011][2];   int main() {     int n, m;     cin >> n >> s + 1 >> m;     for (int i = 1; i <= n; i++) {       if (s[i] !=  b ) mx[i][0] = mx[i - 1][1] + 1;       if (s[i] !=  a ) mx[i][1] = mx[i - 1][0] + 1;       cnt[i] = cnt[i - 1] + (s[i] ==  ? );       dp[i] = dp[i - 1];       if (mx[i][!(m & 1)] >= m) {         if (dp[i - m].first + 1 == dp[i].first) {           smin(dp[i].second, dp[i - m].second + cnt[i] - cnt[i - m]);         }         if (dp[i - m].first + 1 > dp[i].first) {           dp[i].first = dp[i - m].first + 1;           dp[i].second = dp[i - m].second + cnt[i] - cnt[i - m];         }       }     }     cout << dp[n].second << endl;     return 0;   }   