#include <bits/stdc++.h>
using namespace std;
const int NR = 2e5 + 10;
void Min(int& x, int y) { x = min(x, y); }
void Max(int& x, int y) { x = max(x, y); }
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int n, m, cnt;
char a[NR], b[NR];
int f[NR], g[NR];
int dp1[NR], dp2[NR];
int main() {
  n = read();
  scanf("%s", a + 1);
  m = read();
  for (int i = 1; i <= n; i++) cnt += (a[i] == '?');
  for (int i = 1; i <= n; i++) {
    if (a[i] == '?' || a[i] == 'b') dp2[i] = dp1[i - 1] + 1;
    if (a[i] == '?' || a[i] == 'a') dp1[i] = dp2[i - 1] + 1;
  }
  for (int i = 1; i <= n; i++) {
    f[i] = f[i - 1], g[i] = g[i - 1] + (a[i] == '?');
    if (((m % 2) ? dp1[i] : dp2[i]) >= m) {
      if (f[i - m] + 1 > f[i] || (g[i - m] > g[i] && f[i - m] + 1 == f[i]))
        f[i] = f[i - m] + 1, g[i] = g[i - m];
    }
  }
  printf("%d\n", cnt - g[n]);
  return 0;
}
