#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = 0;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return f ? x : -x;
}
const long long N = 1e5 + 5;
long long n, m, f[N], g[N], pre[N], h[2][N];
char ch[N];
signed main() {
  n = read();
  scanf("%s", ch + 1);
  m = read();
  for (long long i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + (ch[i] == '?');
    if (ch[i] != 'a') h[0][i] = h[1][i - 1] + 1;
    if (ch[i] != 'b') h[1][i] = h[0][i - 1] + 1;
    f[i] = f[i - 1];
    g[i] = g[i - 1];
    if (h[m & 1][i] >= m) {
      if (f[i] < f[i - m] + 1)
        f[i] = f[i - m] + 1, g[i] = g[i - m] + pre[i] - pre[i - m];
      else if (f[i] == f[i - m] + 1)
        g[i] = min(g[i], g[i - m] + pre[i] - pre[i - m]);
    }
  }
  printf("%lld", g[n]);
  return 0;
}
