#include <bits/stdc++.h>
using namespace std;
int mx[100100][2], cnt[100100];
pair<int, int> dp[100100];
char str[100100];
int main() {
  int n, m;
  cin >> n;
  scanf("%s", str + 1);
  cin >> m;
  for (int i = 1; i <= n; i++) {
    if (str[i] != 'b') mx[i][0] = mx[i - 1][1] + 1;
    if (str[i] != 'a') mx[i][1] = mx[i - 1][0] + 1;
    cnt[i] = cnt[i - 1] + (str[i] == '?');
    dp[i] = dp[i - 1];
    if ((m % 2 && mx[i][0] >= m) || (m % 2 == 0 && mx[i][1] >= m)) {
      int n1 = dp[i - m].first + 1;
      int n2 = dp[i - m].second + cnt[i] - cnt[i - m];
      if (n1 > dp[i].first || (n1 == dp[i].first && n2 < dp[i].second))
        dp[i] = make_pair(n1, n2);
    }
  }
  printf("%d\n", dp[n].second);
  return 0;
}
