#include <bits/stdc++.h>
using namespace std;
int const bound = 1e6 + 2, N = 5e5 + 1;
long long OO = 1e18;
double eps = 1e-6;
int oo = 1e9, mod = 1e8;
int n, m, cnt[2][2][N];
char cc[N];
pair<int, int> dp[N];
pair<int, int> rec(int idx) {
  pair<int, int> &ret = dp[idx];
  if (ret.first != -1) return ret;
  if (idx == n) return ret = {0, 0};
  if (idx + m - 1 >= n) return ret = {0, 0};
  int a, b, q;
  b = cnt[1][idx & 1][idx] - cnt[1][idx & 1][idx + m];
  a = cnt[0][!(idx & 1)][idx] - cnt[0][!(idx & 1)][idx + m];
  if (a || b) return ret = rec(idx + 1);
  pair<int, int> r1 = rec(idx + 1);
  pair<int, int> r2 = rec(idx + m);
  r2.first++;
  r2.second += m - (cnt[0][idx & 1][idx] - cnt[0][idx & 1][idx + m] +
                    cnt[1][!(idx & 1)][idx] - cnt[1][!(idx & 1)][idx + m]);
  if (r2.first > r1.first) return ret = r2;
  if (r1.first > r2.first) return ret = r1;
  return ret = min(r1, r2);
}
int main() {
  scanf("%d%s%d", &n, cc, &m);
  for (int(i) = 0; (i) < (n); (i)++) {
    if (cc[i] == '?') continue;
    cnt[cc[i] - 'a'][i & 1][i] = 1;
  }
  for (int i = n - 1; i > -1; i--)
    for (int(j) = 0; (j) < (2); (j)++)
      cnt[j][0][i] += cnt[j][0][i + 1], cnt[j][1][i] += cnt[j][1][i + 1];
  for (int(i) = 0; (i) < (n + 1); (i)++) dp[i] = {-1, -1};
  pair<int, int> res = rec(0);
  printf("%d", res.second);
  return 0;
}
