#include <bits/stdc++.h>
using namespace std;
string str;
int n, m;
int dp[100010][2], ar[100010], csum[100010];
int rec(int p, int v) {
  if (p == n) return 0;
  if (v == 0 && str[p] == 'b') return 0;
  if (v == 1 && str[p] == 'a') return 0;
  if (dp[p][v] != -1) return dp[p][v];
  return dp[p][v] = 1 + rec(p + 1, (v + 1) % 2);
}
pair<int, int> dop[100010];
pair<int, int> dude(int p) {
  if (p >= n) return make_pair(0, 0);
  if (dop[p].first != -1) return dop[p];
  if (ar[p] >= m) {
    pair<int, int> a = dude(p + 1);
    pair<int, int> b = dude(p + m);
    b.first += 1;
    b.second += csum[p + m - 1];
    if (p != 0) b.second -= csum[p - 1];
    if (a.first > b.first)
      return dop[p] = a;
    else if (a.first == b.first && a.second < b.second)
      return dop[p] = a;
    return dop[p] = b;
  }
  return dop[p] = dude(p + 1);
}
int main() {
  ios::sync_with_stdio(false);
  memset(dp, -1, sizeof(dp));
  memset(dop, -1, sizeof(dop));
  int i, j, c = 0;
  cin >> n;
  cin >> str;
  cin >> m;
  for (int i = 0; i <= n - 1; i++) {
    if (str[i] == '?') c++;
    csum[i] = c;
    ar[i] = rec(i, 0);
  }
  dude(0);
  cout << dop[0].second << '\n';
  return 0;
}
