#include <bits/stdc++.h>
using namespace std;
char s[100005];
int a[2][100005], b[2][100005], q[100005];
int dp[2][100005];
int dp2[2][100005];
int main() {
  int n, m;
  scanf("%d%s%d", &n, s + 1, &m);
  for (int i = 1; i <= n; i++) {
    if (s[i] == '?')
      q[i]++;
    else if (s[i] == 'a')
      a[i % 2][i]++;
    else if (s[i] == 'b')
      b[i % 2][i]++;
    q[i] += q[i - 1];
    a[0][i] += a[0][i - 1];
    a[1][i] += a[1][i - 1];
    b[0][i] += b[0][i - 1];
    b[1][i] += b[1][i - 1];
  }
  if (m == 1) {
    printf("%d\n", q[n]);
    return 0;
  }
  int aa = (m + 1) / 2, bb = m / 2;
  for (int i = m; i <= n; i++) {
    int cnta = 0, cntb = 0, cntq = 0;
    if (aa == bb) {
      cnta = a[1 - i % 2][i] - a[1 - i % 2][i - m];
      cntb = b[i % 2][i] - b[i % 2][i - m];
      cntq = q[i] - q[i - m];
    } else {
      cnta = a[i % 2][i] - a[i % 2][i - m];
      cntb = b[1 - i % 2][i] - b[1 - i % 2][i - m];
      cntq = q[i] - q[i - m];
    }
    bool ok = 0;
    if (cnta + cntb + cntq == m) ok = 1;
    if (ok) {
      dp[0][i] = dp2[0][i - m] + 1;
      dp[1][i] = dp2[1][i - m] + cntq;
    } else {
      dp[0][i] = dp2[0][i - 1];
      dp[1][i] = dp2[1][i - 1];
    }
    dp2[0][i] = dp[0][i];
    dp2[1][i] = dp[1][i];
    if (dp2[0][i] < dp2[0][i - 1] ||
        (dp2[0][i] == dp2[0][i - 1] && dp2[1][i] > dp2[1][i - 1])) {
      dp2[0][i] = dp2[0][i - 1];
      dp2[1][i] = dp2[1][i - 1];
    }
  }
  printf("%d\n", dp2[1][n]);
}
