#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m;
char s[N];
int dp1[N], dp2[N], h[N][4], sum[N];
int main() {
  cin >> n >> (s + 1) >> m;
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1];
    if (s[i] == '?') sum[i]++;
    if (s[i] != 'a') h[i][0] = h[i - 1][1] + 1;
    if (s[i] != 'b') h[i][1] = h[i - 1][0] + 1;
    dp1[i] = dp1[i - 1];
    dp2[i] = dp2[i - 1];
    if (h[i][m % 2] >= m) {
      if (dp1[i - 1] < dp1[i - m] + 1) {
        dp1[i] = dp1[i - m] + 1;
        dp2[i] = dp2[i - m] + sum[i] - sum[i - m];
      } else if (dp1[i - 1] == dp1[i - m] + 1) {
        dp1[i] = dp1[i - m] + 1;
        dp2[i] = min(dp2[i - 1], dp2[i - m] + sum[i] - sum[i - m]);
      }
    }
  }
  cout << dp2[n];
  return 0;
}
