#include <bits/stdc++.h>
using namespace std;
int dp[2][100005], ans[2][100005];
char s[100005];
int val[100005], cost[100005];
int main() {
  int n;
  int m;
  scanf("%d%s%d", &n, s + 1, &m);
  for (int i = 1; i <= n; i++) {
    if (s[i] != 'b') {
      dp[0][i] = dp[1][i - 1] + 1;
      ans[0][i] = ans[1][i - 1] + (s[i] == '?');
      while (dp[0][i] > m) {
        dp[0][i]--;
        if (s[i - dp[0][i]] == '?') ans[0][i]--;
      }
    }
    if (s[i] != 'a') {
      dp[1][i] = dp[0][i - 1] + 1;
      ans[1][i] = ans[0][i - 1] + (s[i] == '?');
      while (dp[1][i] > m) {
        dp[1][i]--;
        if (s[i - dp[1][i]] == '?') ans[1][i]--;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    val[i] = val[i - 1];
    cost[i] = cost[i - 1];
    if (dp[!(m % 2)][i] == m) {
      if (val[i - m] + 1 >= val[i]) {
        if (val[i - m] + 1 > val[i]) {
          val[i] = val[i - m] + 1;
          cost[i] = cost[i - m] + ans[!(m % 2)][i];
        }
        if (cost[i - m] + ans[!(m % 2)][i] < cost[i])
          cost[i] = cost[i - m] + ans[!(m % 2)][i];
      }
    }
  }
  printf("%d\n", cost[n]);
  return 0;
}
