#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
long long ml[((long long)(1e6 + 900))][2];
pair<long long, long long> dp[((long long)(1e6 + 900))];
long long ct[((long long)(1e6 + 900))];
long long n, m;
string s;
int main() {
  cin >> n >> s >> m;
  s = "*" + s;
  ml[0][0] = -((long long)(1ll << 41));
  ml[0][1] = -((long long)(1ll << 41));
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == 'a') {
      ml[i][0] = max(1ll, ml[i - 1][1] + 1);
      ml[i][1] = -((long long)(1ll << 41));
    } else if (s[i] == 'b') {
      ml[i][0] = -((long long)(1ll << 41));
      ml[i][1] = max(1ll, ml[i - 1][0] + 1);
    } else {
      ml[i][0] = max(1ll, ml[i - 1][1] + 1);
      ml[i][1] = max(1ll, ml[i - 1][0] + 1);
    }
    ct[i] = ct[i - 1] + (s[i] == '?');
  }
  dp[0] = {0, 0};
  for (int i = 1; i < s.size(); i++) {
    dp[i] = dp[i - 1];
    if (ml[i][(m - 1) & 1] >= m)
      dp[i] = max(
          dp[i], {dp[i - m].first + 1, dp[i - m].second - (ct[i] - ct[i - m])});
  }
  cout << -dp[s.size() - 1].second;
}
