#include <bits/stdc++.h>
using namespace std;
template <typename T>
T BigMod(T b, T p, T m) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    T s = BigMod(b, p / 2, m);
    return ((s % m) * (s % m)) % m;
  }
  return ((b % m) * (BigMod(b, p - 1, m) % m)) % m;
}
template <typename T>
T ModInv(T b, T m) {
  return BigMod(b, m - 2, m);
}
template <typename T>
T gcd(T a, T b) {
  if (!b) return a;
  return gcd(b, a % b);
}
char s[100007];
long long a[100007], oa[100007], ob[100007], coa[100007], cob[100007],
    ea[100007], eb[100007], cea[100007], ceb[100007];
long long dp[100007 * 2], qs[100007], cqs[100007], ans[100007];
long long oddack(long long st, long long ed) {
  return (st == 0) ? coa[ed] : coa[ed] - coa[st - 1];
}
long long oddbck(long long st, long long ed) {
  return (st == 0) ? cob[ed] : cob[ed] - cob[st - 1];
}
long long evnack(long long st, long long ed) {
  return (st == 0) ? cea[ed] : cea[ed] - cea[st - 1];
}
long long evnbck(long long st, long long ed) {
  return (st == 0) ? ceb[ed] : ceb[ed] - ceb[st - 1];
}
long long n, x;
long long call(long long p) {
  if (p >= n) {
    dp[p] = 0;
    return dp[p];
  }
  if (dp[p] != -1) return dp[p];
  long long res = call(p + 1);
  if (a[p]) res = max(res, a[p] + call(p + x));
  return dp[p] = res;
}
long long path(long long p) {
  if (p >= n) return 0;
  if (ans[p] != -1) return ans[p];
  long long res = 10000000000;
  if (dp[p] == dp[p + 1]) res = min(res, path(p + 1));
  if (a[p] && dp[p] == a[p] + dp[p + x])
    res = min(res, path(p + x) + (cqs[p + x - 1] - ((p > 0) ? cqs[p - 1] : 0)));
  return ans[p] = res;
}
int main() {
  long long i, j, k, l, r, st, ed, pos, val, p, y, c, sum, cnt, dif, idx, m, q;
  scanf("%lld", &n);
  scanf("%s", &s);
  scanf("%lld", &x);
  for (i = 0; i <= n - 1; i++) {
    if (s[i] == '?') qs[i] = 1;
    if (!(i & 1ll)) {
      if (s[i] == 'a')
        ea[i] = 1;
      else if (s[i] == 'b')
        eb[i] = 1;
    } else {
      if (s[i] == 'a')
        oa[i] = 1;
      else if (s[i] == 'b')
        ob[i] = 1;
    }
  }
  for (i = 0; i <= n - 1; i++) {
    if (!i) {
      coa[i] = oa[i];
      cob[i] = ob[i];
      cea[i] = ea[i];
      ceb[i] = eb[i];
      cqs[i] = qs[i];
    } else {
      coa[i] = oa[i] + coa[i - 1];
      cob[i] = ob[i] + cob[i - 1];
      cea[i] = ea[i] + cea[i - 1];
      ceb[i] = eb[i] + ceb[i - 1];
      cqs[i] = qs[i] + cqs[i - 1];
    }
  }
  for (i = 0, j = i + x - 1; j < n; j++, i++) {
    cnt = 0;
    if (!(i & 1ll)) {
      cnt += oddack(i, j);
      cnt += evnbck(i, j);
    } else {
      cnt += oddbck(i, j);
      cnt += evnack(i, j);
    }
    a[i] = (cnt == 0);
  }
  memset(dp, -1, sizeof dp);
  memset(ans, -1, sizeof ans);
  call(0);
  cout << path(0) << endl;
  return 0;
}
