#include <bits/stdc++.h>
using namespace std;
int n, m, a[100001], b[100001], c[100001], d[2][100001];
string s;
inline long long read() {
  long long sum = 0, x = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') x = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  return sum * x;
}
inline void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  return;
}
int main() {
  n = read();
  cin >> s;
  m = read();
  for (register int i = 1; i <= n; ++i) {
    a[i] = a[i - 1] + (s[i - 1] == '?');
    if (s[i - 1] != 'a') d[0][i] = d[1][i - 1] + 1;
    if (s[i - 1] != 'b') d[1][i] = d[0][i - 1] + 1;
    c[i] = c[i - 1];
    b[i] = b[i - 1];
    if (d[m & 1][i] >= m) {
      if (c[i] < c[i - m] + 1) {
        c[i] = c[i - m] + 1;
        b[i] = b[i - m] + a[i] - a[i - m];
      } else if (c[i] == c[i - m] + 1)
        b[i] = min(b[i], b[i - m] + a[i] - a[i - m]);
    }
  }
  write(b[n]);
  return 0;
}
