#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
void chkmax(T1& x, T2 y) {
  if (x < y) x = y;
}
template <typename T1, typename T2>
void chkmin(T1& x, T2 y) {
  if (x > y) x = y;
}
const int MAXN = 1e5 + 1;
int cnt[2][2];
string second;
pair<int, int> dp[MAXN], cur = {0, 0};
void add(int pos, int val) {
  if (pos < 0 || second[pos] == '?') return;
  cnt[second[pos] - 'a'][pos & 1] += val;
}
void upd_val(int pos) {
  if (pos < 0) return;
  if (cur.first < dp[pos].first ||
      cur.first == dp[pos].first && cur.second > dp[pos].second)
    cur = dp[pos];
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n, m;
  cin >> n >> second >> m;
  for (int i = 0; i < n; ++i) {
    add(i, 1), add(i - m, -1), upd_val(i - m);
    if (i < m - 1) continue;
    if ((i - m + 1) % 2 == 0) {
      if (cnt[1][0] == 0 && cnt[0][1] == 0) {
        dp[i] = {cur.first + 1, cur.second + m - cnt[1][1] - cnt[0][0]};
      }
    } else {
      if (cnt[0][0] == 0 && cnt[1][1] == 0) {
        dp[i] = {cur.first + 1, cur.second + m - cnt[0][1] - cnt[1][0]};
      }
    }
  }
  for (int i = 0; i < n; ++i) upd_val(i);
  cout << cur.second;
  return 0;
}
