#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int ps[MAXN];
pair<int, int> dp[MAXN];
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  ps[0] = s[0] == '?' ? 1 : 0;
  for (int i = 1; i < n; i++) {
    ps[i] = ps[i - 1] + (s[i] == '?' ? 1 : 0);
  }
  ps[n] = ps[n - 1];
  int m;
  cin >> m;
  int la[2] = {-1, -1}, lb[2] = {-1, -1};
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a') la[i % 2] = i;
    if (s[i] == 'b') lb[i % 2] = i;
    int st = i - m + 1;
    dp[i + 1] = dp[i];
    if (st < 0) continue;
    if (lb[st % 2] <= st - 1 && la[(st + 1) % 2] <= st - 1) {
      dp[i + 1] = max(
          dp[i + 1],
          make_pair(dp[st].first + 1, -(-dp[st].second + ps[i] - ps[st - 1])));
    }
  }
  cout << -dp[n].second << endl;
  return 0;
}
