#include <bits/stdc++.h>
using namespace std;
int best[100010], n, m, ps[100010], psa[2][100010], psb[2][100010], dp[100010],
    mf[100010];
string str, foo;
inline int ask(int x, int y, int *ps) {
  if (y > n) y = n;
  return ps[y] - ps[x];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> str >> m;
  for (int i = 1; i <= n; i++) ps[i] = ps[i - 1] + (str[i - 1] == '?');
  for (int i = 1, j = 0; i <= n; i++, j ^= 1) {
    psa[0][i] = psa[0][i - 1];
    psb[0][i] = psb[0][i - 1];
    psb[1][i] = psb[1][i - 1];
    psa[1][i] = psa[1][i - 1];
    if (str[i - 1] != 'a') psb[j][i]++;
    if (str[i - 1] != 'b') psa[j][i]++;
  }
  for (int i = n - m; i >= 0; i--) {
    mf[i] = (ask(i, i + m, psa[i % 2]) + ask(i, i + m, psb[(i % 2) ^ 1]) == m);
    best[i] = max(best[i + 1], best[i + m] + mf[i]);
  }
  for (int i = n - m; i >= 0; i--) {
    if (mf[i])
      dp[i] = ask(i, i + m, ps) + dp[i + m];
    else
      dp[i] = dp[i + 1];
    if (best[i] == best[i + 1]) dp[i] = min(dp[i + 1], dp[i]);
  }
  cout << dp[0] << endl;
  return 0;
}
