#include <bits/stdc++.h>
using namespace std;
char s[100100];
int dpm[100100];
int dpc[100100];
int nx[100100];
unordered_map<int, int> dp[100100];
int n, m;
void build(int off) {
  int cnt = 0, cur = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == (i % 2 == off ? 'a' : 'b') || s[i] == '?') cur++;
    if (s[i] == '?') cnt++;
    int j = i - m + 1;
    if (j % 2 == off && cur == m) {
      dpc[j] = cnt;
    }
    if (j > 0 && (s[j] == (j % 2 == off ? 'a' : 'b') || s[j] == '?')) cur--;
    if (j > 0 && s[j] == '?') cnt--;
  }
}
int solve(int occ, int i) {
  if (occ == 0) return 0;
  if (dp[occ].count(i)) return dp[occ][i];
  i = nx[i];
  if (dp[occ].count(i)) return dp[occ][i];
  int j = i;
  while (dpm[j] >= occ) j++;
  int mmin = INT_MAX;
  while (j > i) {
    j--;
    if (dpc[j] > -1) mmin = min(mmin, dpc[j] + solve(occ - 1, j + m));
    dp[occ][j] = mmin;
  }
  return mmin;
}
int main() {
  scanf("%d", &(n));
  scanf("%s", s + 1);
  scanf("%d", &(m));
  for (int i = 1; i <= n; i++) dpc[i] = -1;
  build(1);
  build(0);
  for (int i = n; i >= 1; i--) {
    dpm[i] = dpm[i + 1];
    if (dpc[i] > -1) {
      dpm[i] = max(dpm[i], dpm[i + m] + 1);
      nx[i] = i;
    } else {
      nx[i] = nx[i + 1];
    }
  }
  int ans = solve(dpm[1], 1);
  cout << ans << endl;
  return 0;
}
