#include <bits/stdc++.h>
using namespace std;
char c[100005];
int cut[100005], num[100005];
int f[100005], h[2][100005];
int main() {
  int n, m;
  cin >> n >> c + 1 >> m;
  for (int i = 1; i <= n; i++) {
    num[i] = num[i - 1];
    if (c[i] == 'a')
      h[0][i] = h[1][i - 1] + 1;
    else if (c[i] == 'b')
      h[1][i] = h[0][i - 1] + 1;
    else {
      h[0][i] = h[1][i - 1] + 1;
      h[1][i] = h[0][i - 1] + 1;
      num[i]++;
    }
    f[i] = f[i - 1], cut[i] = cut[i - 1];
    if (h[(m + 1) & 1][i] >= m) {
      if (f[i] < f[i - m] + 1) {
        f[i] = f[i - m] + 1, cut[i] = cut[i - m] + num[i] - num[i - m];
      }
      if (f[i] == f[i - m] + 1) {
        cut[i] = min(cut[i], cut[i - m] + num[i] - num[i - m]);
      }
    }
  }
  cout << cut[n] << endl;
}
