#include <bits/stdc++.h>
using namespace std;
inline pair<int, int> best(pair<int, int> a, pair<int, int> b) {
  if ((a.first > b.first) || ((a.first == b.first) && (a.second < b.second)))
    return a;
  return b;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  string s;
  cin >> n;
  cin >> s;
  cin >> m;
  vector<vector<int> > ka(n, vector<int>(2));
  vector<vector<int> > kb(n, vector<int>(2));
  vector<int> kv(n);
  vector<int> preva(n, -1);
  if (s[0] == 'a') {
    preva[0] = 0;
    ka[0][0] = 1;
  }
  if (s[0] == 'b') kb[0][0] = 1;
  if (s[0] == '?') kv[0] = 1, preva[0] = 0;
  for (int i = 1; i < n; i++) {
    ka[i][0] = ka[i - 1][0];
    ka[i][1] = ka[i - 1][1];
    if (s[i] == 'a') ka[i][i % 2]++;
    kb[i][0] = kb[i - 1][0];
    kb[i][1] = kb[i - 1][1];
    if (s[i] == 'b') kb[i][i % 2]++;
    if ((s[i] == 'a') || (s[i] == '?'))
      preva[i] = i;
    else
      preva[i] = preva[i - 1];
    kv[i] = kv[i - 1];
    if (s[i] == '?') kv[i]++;
  }
  vector<vector<pair<int, int> > > dp(n, vector<pair<int, int> >(2));
  if (((s[0] == 'a') || (s[0] == '?')) && (m <= n) && (kb[m - 1][0] == 0) &&
      (ka[m - 1][1] == 0))
    dp[0][1] = {1, kv[m - 1]};
  for (int i = 1; i < n; i++) {
    dp[i][0] = best(dp[i - 1][0], dp[i - 1][1]);
    if (i + m - 1 >= n) continue;
    int bada = ka[i + m - 1][(i % 2) ^ 1] - ka[i - 1][(i % 2) ^ 1];
    int badb = kb[i + m - 1][i % 2] - kb[i - 1][i % 2];
    if ((bada != 0) || (badb != 0)) continue;
    if (i < m) {
      dp[i][1] = {1, kv[i + m - 1] - kv[i - 1]};
    } else {
      int p = preva[i - m];
      if (p < 0) {
        dp[i][1] = {1, kv[i + m - 1] - kv[i - 1]};
      } else {
        dp[i][1] = best(dp[p][0], dp[p][1]);
        dp[i][1].first++;
        dp[i][1].second += kv[i + m - 1] - kv[i - 1];
      }
    }
  }
  pair<int, int> rez = best(dp[n - 1][0], dp[n - 1][1]);
  cout << rez.second << "\n";
  return 0;
}
