#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5, maxM = 500, MOD = 1e9 + 7;
const char ab[2] = {'a', 'b'};
pair<int, int> dp[maxN << 1];
int bads[maxN + 1], n, m, ac[maxN + 1];
void add(const string &a, int c) {
  bads[a.length()] = 0;
  for (int i = a.length() - 1; i >= 0; i--)
    bads[i + c] =
        bads[i + 1 + c] + ((a[i] == '?' || a[i] == ab[i & 1]) ? 0 : 1);
  for (int i = c; i + m <= n; i += 2)
    if (bads[i] == bads[i + m])
      dp[i + n] = pair<int, int>(1, ac[i] - ac[i + m]);
}
pair<int, int> big(const pair<int, int> &a, const pair<int, int> &b) {
  return a.first > b.first || (a.first == b.first && a.second < b.second) ? a
                                                                          : b;
}
pair<int, int> sum(const pair<int, int> &a, const pair<int, int> &b) {
  return pair<int, int>(a.first + b.first, a.second + b.second);
}
pair<int, int> query(int l, int r) {
  pair<int, int> ans(0, 0);
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ans = big(ans, dp[l++]);
    if (r & 1) ans = big(ans, dp[--r]);
  }
  return ans;
}
void update(int w, pair<int, int> val) {
  for (dp[w += n] = val; w > 1;)
    w >>= 1, dp[w] = big(dp[w << 1], dp[w << 1 | 1]);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  string st;
  cin >> n >> st >> m;
  for (int i = n - 1; i >= 0; i--) ac[i] = ac[i + 1] + (st[i] == '?' ? 1 : 0);
  add(st, 0), add(st.substr(1), 1);
  pair<int, int> ans(0, 0);
  for (int i = n - 1; i; i--) dp[i] = big(dp[i << 1], dp[i << 1 | 1]);
  for (int i = n - m; i >= 0; i--) {
    update(i, sum(dp[i + n], query(i + m, n)));
    ans = big(dp[i + n], ans);
  }
  cout << ans.second << '\n';
}
