#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const long long ooo = 9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
const int _p = 1000 * 1000 * 1000 + 7;
const int N = 100105;
const double PI = acos(-1.0);
const double eps = 1e-6;
int o(int x) { return x % _p; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
void file_put() {
  freopen("filename.in", "r", stdin);
  freopen("filename.out", "w", stdout);
}
struct ttype {
  int x, y;
  ttype(int _x = 0, int _y = oo) { x = _x, y = _y; }
  friend bool operator>(const ttype &p, const ttype &q) {
    return p.x > q.x || p.x == q.x && p.y < q.y;
  }
};
char st[N];
int a[2][N], b[2][N], c[N], n, m, op;
ttype dp[N], temp;
bool p[N];
int main() {
  scanf("%d%s%d", &n, st + 1, &m);
  a[0][0] = b[0][0] = a[1][0] = b[1][0] = c[0] = 0;
  memset(p, 0, sizeof(p));
  for (int i = (1); i <= (n); ++i)
    if (i & 1) {
      a[1][i] = a[1][i - 1] + (st[i] != 'b');
      a[0][i] = a[0][i - 1];
      b[1][i] = b[1][i - 1] + (st[i] != 'a');
      b[0][i] = b[0][i - 1];
    } else {
      a[0][i] = a[0][i - 1] + (st[i] != 'b');
      a[1][i] = a[1][i - 1];
      b[0][i] = b[0][i - 1] + (st[i] != 'a');
      b[1][i] = b[1][i - 1];
    }
  for (int i = (1); i <= (n); ++i) c[i] = c[i - 1] + (st[i] == '?');
  for (int i = (m); i <= (n); ++i) {
    op = ((i - m + 1) & 1), p[i] = 1;
    p[i] &= (a[op][i] - a[op][i - m] == (m + 1) / 2);
    p[i] &= (b[op ^ 1][i] - b[op ^ 1][i - m] == m / 2);
  }
  dp[0].y = 0;
  for (int i = (1); i <= (n); ++i) {
    if (i >= m && p[i])
      dp[i] = ttype(dp[i - m].x + 1, dp[i - m].y + c[i] - c[i - m]);
    dp[i] = ((dp[i]) > (dp[i - 1]) ? (dp[i]) : (dp[i - 1]));
  }
  printf("%d\n", dp[n].y);
  return 0;
}
