#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
int n, m;
char s[MAXN];
void load() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  scanf("%d", &m);
}
int occ[MAXN][2];
pair<int, int> dp[MAXN];
int numU[MAXN];
int num_U(int l, int r) { return numU[r] - numU[l - 1]; }
void set_best(pair<int, int> &a, pair<int, int> b) {
  if (a.first == b.first) {
    if (a.second > b.second) a = b;
  } else if (a.first < b.first)
    a = b;
}
void solve() {
  for (int c = 0; c < 2; c++) {
    int br = 0;
    char ch = 'a' + c;
    for (int i = n; i > 0; i -= 2) {
      if (s[i] == '?' || s[i] == ch)
        br++;
      else
        br = 0;
      occ[i][c] = br;
    }
    for (int i = n - 1; i > 0; i -= 2) {
      if (s[i] == '?' || s[i] == ch)
        br++;
      else
        br = 0;
      occ[i][c] = br;
    }
  }
  for (int i = 1; i <= n; i++) {
    numU[i] = numU[i - 1] + (s[i] == '?');
  }
  int numA = (m + 1) / 2, numB = m / 2;
  pair<int, int> best(0, 0);
  for (int i = 1; i <= n; i++) {
    if (occ[i][0] >= numA && occ[i + 1][1] >= numB) {
      set_best(
          dp[i + m - 1],
          pair<int, int>(best.first + 1, best.second + num_U(i, i + m - 1)));
    }
    set_best(dp[i], best);
    set_best(best, dp[i]);
  }
  printf("%d\n", dp[n].second);
}
int main() {
  load();
  solve();
  return 0;
}
