#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
pair<int, int> a[N];
int f[N];
char s[N];
int n, m;
int cc[2][N];
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  scanf("%d", &m);
  if (m > n) return 0 * puts("0");
  for (int i(1); i <= (n); ++i) {
    cc[1][i] = s[i] != 'b' ? (cc[0][i - 1] + 1) : 0;
    cc[0][i] = s[i] != 'a' ? (cc[1][i - 1] + 1) : 0;
  }
  for (int i(1); i <= (n); ++i)
    if (s[i] == '?')
      f[i] = f[i - 1] + 1;
    else
      f[i] = f[i - 1];
  for (int i(m); i <= (n); ++i) {
    if (cc[m & 1][i] >= m)
      a[i] = make_pair(a[i - m].first + 1, a[i - m].second - f[i] + f[i - m]);
    a[i] = max(a[i], a[i - 1]);
  }
  printf("%d\n", -a[n].second);
  return 0;
}
