#include <bits/stdc++.h>
using namespace std;
int n, m;
int f[210000], g[210000], p[210000], h[2][210000];
string s;
int main() {
  cin >> n >> s >> m;
  s = " " + s;
  for (int i = 1; i <= n; i++) {
    p[i] = p[i - 1], f[i] = f[i - 1], g[i] = g[i - 1];
    if (s[i] == '?') p[i]++;
    if (s[i] != 'a') h[0][i] = h[1][i - 1] + 1;
    if (s[i] != 'b') h[1][i] = h[0][i - 1] + 1;
    if (h[m % 2][i] >= m) {
      if (f[i] < f[i - m] + 1)
        f[i] = f[i - m] + 1, g[i] = g[i - m] + p[i] - p[i - m];
      else if (f[i] == f[i - m] + 1)
        g[i] = min(g[i], g[i - m] + p[i] - p[i - m]);
    }
  }
  cout << g[n];
  return 0;
}
