#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const long long INFL = 1e18 + 123;
const double PI = atan2(0, -1);
mt19937 tw(960172);
long long rnd(long long x, long long y) {
  static uniform_int_distribution<long long> d;
  return d(tw) % (y - x + 1) + x;
}
const int MAXL = 1e5 + 5, MAXN = 1e5 + 5;
char buf[MAXL];
pair<int, int> d[MAXN];
int main() {
  cerr << fixed << setprecision(15);
  cout << fixed << setprecision(15);
  int n, m;
  scanf("%d", &n);
  scanf("%s", buf);
  scanf("%d", &m);
  vector<int> poses[2][2];
  vector<int> ques;
  for (int i = 0; i < n; ++i) {
    if (buf[i] != '?') {
      poses[i % 2][buf[i] - 'a'].push_back(i);
    }
    ques.push_back(buf[i] == '?');
  }
  vector<int> pref = {0};
  for (int num : ques) {
    pref.push_back(num + pref.back());
  }
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      poses[i][j].push_back(MAXL);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (i + m <= n) {
      if (i + m <=
              *lower_bound(begin(poses[i % 2][1]), end(poses[i % 2][1]), i) &&
          i + m <= *lower_bound(begin(poses[1 - i % 2][0]),
                                end(poses[1 - i % 2][0]), i)) {
        d[i + m] = max(d[i + m],
                       {d[i].first + 1, d[i].second - (pref[i + m] - pref[i])});
      }
    }
    d[i + 1] = max(d[i + 1], d[i]);
  }
  cout << -d[n].second << "\n";
  return 0;
}
