#include <bits/stdc++.h>
using namespace std;
pair<int, int> ans[100100];
int f[100100][2], cnt[100100];
char s[100100];
int n, m;
int main() {
  scanf("%d\n", &n);
  scanf("%s\n", &s);
  scanf("%d\n", &m);
  for (int i = 1; i <= n; i++) {
    cnt[i] = cnt[i - 1] + (s[i - 1] == '?');
    if (s[i - 1] != 'a') f[i][1] = f[i - 1][0] + 1;
    if (s[i - 1] != 'b') f[i][0] = f[i - 1][1] + 1;
    if (f[i][(m + 1) & 1] >= m) {
      ans[i].first = ans[i - m].first + 1;
      ans[i].second = ans[i - m].second - cnt[i] + cnt[i - m];
    }
    ans[i] = max(ans[i], ans[i - 1]);
  }
  printf("%d\n", -ans[n].second);
  return 0;
}
