#include <bits/stdc++.h>
using namespace std;
int dp1[100005][2];
pair<int, int> dp2[100005];
int pre[100005];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int m;
  cin >> m;
  pre[0] = 0;
  for (int i = 0; i < n; i++) {
    pre[i + 1] = pre[i];
    if (s[i] == '?') {
      pre[i + 1]++;
    }
  }
  dp1[n][0] = dp1[n][1] = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'a') {
      dp1[i][1] = 0;
      dp1[i][0] = 1 + dp1[i + 1][1];
    } else if (s[i] == 'b') {
      dp1[i][0] = 0;
      dp1[i][1] = 1 + dp1[i + 1][0];
    } else {
      dp1[i][1] = 1 + dp1[i + 1][0];
      dp1[i][0] = 1 + dp1[i + 1][1];
    }
  }
  dp2[n] = {0, 0};
  for (int i = n - 1; i >= 0; i--) {
    if (dp1[i][0] < m) {
      dp2[i] = dp2[i + 1];
    } else {
      dp2[i] = dp2[i + 1];
      pair<int, int> temp;
      temp.first = 1 + dp2[i + m].first;
      temp.second = pre[i + m] - pre[i] + dp2[i + m].second;
      if (temp.first > dp2[i].first) {
        dp2[i] = temp;
      } else if (temp.first == dp2[i].first) {
        dp2[i].second = min(temp.second, dp2[i].second);
      }
    }
  }
  cout << dp2[0].second << "\n";
  return 0;
}
