#include <bits/stdc++.h>
using namespace std;
inline long long in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
const long long maxn = 1e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 10;
long long pref[2][maxn], pref2[maxn];
long long maxDp[maxn], minDp[maxn];
int32_t main() {
  long long n = in();
  string s;
  cin >> s;
  long long lenT = in();
  long long cntA = (lenT + 1) / 2;
  long long cntB = lenT / 2;
  for (long long i = 0; i < n; i++) {
    pref[0][i + 1] = (i ? pref[0][i - 1] : 0) + (s[i] != 'b');
    if (i - cntA * 2 >= 0) pref[0][i + 1] -= (s[i - cntA * 2] != 'b');
    pref[1][i + 1] = (i ? pref[1][i - 1] : 0) + (s[i] != 'a');
    if (i - cntB * 2 >= 0) pref[1][i + 1] -= (s[i - cntB * 2] != 'a');
    pref2[i + 1] =
        pref2[i] + (s[i] == '?') - (i >= lenT ? (s[i - lenT] == '?') : 0);
  }
  for (long long i = 0; i < n; i++) {
    if (i + 1 < lenT) continue;
    maxDp[i + 1] = maxDp[i];
    long long value = maxDp[i - lenT + 1];
    bool fl = (pref[1][i + 1 * bool(lenT % 2 == 0)] +
               pref[0][i + 1 * bool(lenT % 2)]) == lenT;
    value += fl;
    maxDp[i + 1] = max(maxDp[i + 1], value);
    long long options[2] = {inf, inf};
    if (maxDp[i + 1] == maxDp[i]) options[0] = minDp[i];
    if (fl) options[1] = minDp[i - lenT + 1] + pref2[i + 1];
    minDp[i + 1] = min(options[0], options[1]);
  }
  cout << minDp[n] << "\n";
}
