#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
inline int rd() {
  int first = 0;
  char p = getchar();
  while (p < '0' || p > '9') p = getchar();
  while (p >= '0' && p <= '9') first = first * 10 + p - '0', p = getchar();
  return first;
}
const int N = 1e6 + 50;
int n, m, dp[N], sum[N][2][2], f[N], c[N];
char s[N];
int chk(int first) {
  if (first < m) return 0;
  int l = first - m + 1, r = first;
  if (sum[r][l & 1][1] - sum[l - 1][l & 1][1]) return 0;
  if (sum[r][l & 1 ^ 1][0] - sum[l - 1][l & 1 ^ 1][0]) return 0;
  return 1;
}
int main() {
  scanf("%d%s%d", &n, s + 1, &m);
  for (int i = 1; i <= n; ++i) {
    memcpy(sum[i], sum[i - 1], sizeof sum[0]);
    if (s[i] != '?') ++sum[i][i & 1][s[i] - 'a'];
    f[i] = f[i - 1] + (s[i] == '?');
  }
  for (int i = 1; i <= n; ++i) {
    dp[i] = dp[i - 1];
    if (chk(i)) dp[i] = max(dp[i], dp[i - m] + 1);
  }
  int pre = 0;
  for (int i = 1; i <= n; ++i) {
    int j = i;
    while (j < n && dp[j + 1] == dp[i]) ++j;
    int now = pre, mi = c[now];
    for (int k = i; k <= j; ++k) {
      while (now <= k - m && dp[now] == dp[i] - 1) mi = min(mi, c[now++]);
      if (chk(k))
        c[k] = mi + f[k] - f[k - m];
      else
        c[k] = c[k - 1];
    }
    pre = i, i = j;
  }
  int ans = 1e9;
  for (int i = 1; i <= n; ++i)
    if (dp[i] == dp[n]) ans = min(ans, c[i]);
  printf("%d\n", ans);
}
