#include <bits/stdc++.h>
using namespace std;
using lli = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vlli = vector<lli>;
const int maxn = 2e5;
struct Val {
  int b, c;
  Val() {}
  Val(int b, int c) : b(b), c(c) {}
  bool operator<(Val v) const {
    if (b != v.b) return b < v.b;
    return c > v.c;
  }
  Val operator+(Val v) { return Val(b + v.b, c + v.c); }
};
const char *t = "ab";
Val val[maxn];
char s[maxn + 1];
Val dp[maxn + 1];
int n, m;
int main() {
  scanf("%d %s%d", &n, s, &m);
  for (int(init) = 0; (init) < 2; ++(init)) {
    int r = 0;
    int c = 0;
    for (int l = init; l < n; l += 2) {
      if (l + m - 1 >= n) break;
      r = max(l, r);
      while (r - l < m) {
        int p = (r - l) % 2;
        if (s[r] == t[1 - p]) break;
        c += s[r] == '?';
        r++;
      }
      if (r - l == m) val[l] = Val(1, c);
      if (r > l && s[l] == '?') c--;
      if (r > l + 1 && l < n - 1 && s[l + 1] == '?') c--;
    }
  }
  dp[0] = Val(0, 0);
  for (int(i) = 0; (i) < n; ++(i)) {
    if (val[i].b) dp[i + m] = max(dp[i + m], dp[i] + val[i]);
    dp[i + 1] = max(dp[i + 1], dp[i]);
  }
  printf("%d\n", dp[n].c);
}
