#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
string str;
pair<int, int> dp[N];
int memo[N][2];
int acc[N];
int n, m;
int sum(int L, int R) {
  if (L) return acc[R] - acc[L - 1];
  return acc[R];
}
int go(int idx, bool flag) {
  if (idx == n) return n;
  int &ret = memo[idx][flag];
  if (~ret) return ret;
  if (str[idx] == '?') return ret = go(idx + 1, !flag);
  if (!flag && str[idx] == 'a') return ret = go(idx + 1, !flag);
  if (flag && str[idx] == 'b') return ret = go(idx + 1, !flag);
  return ret = idx;
}
pair<int, int> solve(int idx) {
  if (idx == n) return {0, 0};
  pair<int, int> &ret = dp[idx];
  if (~ret.first) return ret;
  ret = solve(idx + 1);
  int lst = go(idx, 0);
  if (lst >= idx + m) {
    pair<int, int> cur = solve(idx + m);
    cur.first++;
    cur.second -= sum(idx, idx + m - 1);
    ret = max(ret, cur);
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> str >> m;
  memset(memo, -1, sizeof memo);
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < int(n); i++) {
    acc[i] = (str[i] == '?');
    if (i) acc[i] += acc[i - 1];
  }
  cout << -solve(0).second << '\n';
  return 0;
}
