#include <bits/stdc++.h>
using namespace std;
int n;
int m;
std::string s;
int arr[4][100010];
int main() {
  std::cin >> n;
  std::cin >> s;
  std::cin >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 4; j++) {
      arr[j][i] += arr[j][i - 1];
    }
    if (s[i - 1] == '?') continue;
    int t = (i & 1) | (s[i - 1] == 'a') << 1;
    arr[t][i]++;
  }
  vector<pair<int, int> > ans(n + 1);
  auto func = [](pair<int, int> x, pair<int, int> y) {
    return make_pair(x.first + y.first, x.second + y.second);
  };
  for (int i = m, j = 1; i <= n; i++, j ^= 1) {
    ans[i] = ans[i - 1];
    if (arr[j][i] - arr[j][i - m] == 0) {
      if (arr[(j ^ 1) + 1 + 1][i] - arr[(j ^ 1) + 1 + 1][i - m] == 0) {
        int tmp = m - (arr[(j ^ 1)][i] - arr[(j ^ 1)][i - m]) -
                  (arr[j + 1 + 1][i] - arr[j + 1 + 1][i - m]);
        tmp = -tmp;
        ans[i] = max(func(ans[i - m], {1, tmp}), ans[i]);
      }
    }
  }
  int res = -ans[n].second;
  std::cout << res << '\n';
  return 0;
}
