#include <bits/stdc++.h>
using namespace std;
int n, m, f[100001][2], cnt[100001];
string s;
pair<int, int> dp[100001];
bool operator>(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
int get(int l, int r) { return cnt[r] - (l ? cnt[l - 1] : 0); }
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> s >> m;
  memset(f, -1, sizeof(f));
  if (s[n - 1] == '?')
    f[n - 1][0] = f[n - 1][1] = n - 1;
  else
    f[n - 1][s[n - 1] - 'a'] = n - 1;
  for (int i = n - 1 - 1; i >= 0; i--) {
    if (s[i] == '?') {
      if (f[i + 1][0] != -1)
        f[i][1] = f[i + 1][0];
      else
        f[i][1] = i;
      if (f[i + 1][1] != -1)
        f[i][0] = f[i + 1][1];
      else
        f[i][0] = i;
    }
    if (s[i] == 'b') {
      if (f[i + 1][0] != -1)
        f[i][1] = f[i + 1][0];
      else
        f[i][1] = i;
    }
    if (s[i] == 'a') {
      if (f[i + 1][1] != -1)
        f[i][0] = f[i + 1][1];
      else
        f[i][0] = i;
    }
  }
  for (int i = 0; i < n; i++) {
    cnt[i] = i ? cnt[i - 1] : 0;
    if (s[i] == '?') cnt[i]++;
  }
  for (int i = 0; i < n; i++) dp[i] = pair<int, int>(0, 0);
  for (int i = 0; i < n; i++) {
    dp[i + 1] = dp[i + 1] > dp[i] ? dp[i + 1] : dp[i];
    if (f[i][0] >= i + m - 1)
      dp[i + m] = dp[i + m] > pair<int, int>(dp[i].first + 1,
                                             dp[i].second + get(i, i + m - 1))
                      ? dp[i + m]
                      : pair<int, int>(dp[i].first + 1,
                                       dp[i].second + get(i, i + m - 1));
  }
  cout << dp[n].second;
  return 0;
}
