#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 19;
char que[maxn], b[maxn];
int dp[maxn], match[maxn], ans[maxn], num[maxn];
bool cheak(int x, int y) {
  if (x == y && que[x] != 'b') return true;
  if (que[x] == 'b') return false;
  int l = x, r = y;
  if (l % 2 == 1 && r % 2 == 1)
    r--;
  else if (l % 2 == 0 && r % 2 == 0)
    r--;
  l--;
  if (match[r] - match[l] == (r - l) / 2)
    if (que[y] == b[y - x + 1] || que[y] == '?') return true;
  return false;
}
int mx[maxn << 2], mn[maxn << 2];
void update(int l, int r, int rt, int q, int val, int num) {
  if (l == r) {
    mx[rt] = val, mn[rt] = num;
    return;
  }
  int mid = l + r >> 1;
  if (q <= mid)
    update(l, mid, rt << 1, q, val, num);
  else
    update(mid + 1, r, rt << 1 | 1, q, val, num);
  mx[rt] = mx[rt << 1];
  mn[rt] = mn[rt << 1];
  if (mx[rt] < mx[rt << 1 | 1])
    mx[rt] = mx[rt << 1 | 1], mn[rt] = mn[rt << 1 | 1];
  else if (mx[rt << 1] == mx[rt << 1 | 1])
    mn[rt] = min(mn[rt << 1], mn[rt << 1 | 1]);
}
pair<int, int> query(int l, int r, int rt, int ql, int qr) {
  if (ql > qr) return {0, 0};
  if (ql <= l && qr >= r) return {mx[rt], mn[rt]};
  int mid = (l + r) >> 1;
  pair<int, int> tp1{0, 102344}, tp2{0, 1010101};
  if (ql <= mid) tp1 = query(l, mid, rt << 1, ql, qr);
  if (qr > mid) tp2 = query(mid + 1, r, rt << 1 | 1, ql, qr);
  pair<int, int> tp = tp1;
  if (tp.first < tp2.first)
    tp = tp2;
  else if (tp1.first == tp2.first)
    tp.second = min(tp2.second, tp1.second);
  return tp;
}
int main() {
  for (int i = 1; i < maxn; ++i)
    if (i & 1)
      b[i] = 'a';
    else
      b[i] = 'b';
  int n, m, k;
  scanf("%d", &n);
  scanf("%s", que + 1);
  scanf("%d", &m);
  for (int i = 1; i <= n; ++i) {
    num[i] = num[i - 1];
    if (que[i] == '?') num[i]++;
  }
  for (int i = 2; i <= n; i++) {
    match[i] = match[i - 2];
    if (que[i] == 'b' && (que[i - 1] == 'a' || que[i - 1] == '?')) match[i]++;
    if (que[i] == '?' && (que[i - 1] == '?' || que[i - 1] == 'a')) match[i]++;
  }
  for (int i = 1; i <= n; ++i) {
    if (i >= m && cheak(i - m + 1, i)) {
      pair<int, int> tp = query(1, n, 1, 1, i - m);
      dp[i] = tp.first + 1;
      ans[i] = tp.second + num[i] - num[i - m];
      update(1, n, 1, i, dp[i], ans[i]);
    }
  }
  int MX = 0, t = 0;
  for (int i = 1; i <= n; ++i) {
    if (MX < dp[i])
      MX = dp[i], t = ans[i];
    else if (MX == dp[i])
      t = min(t, ans[i]);
  }
  printf("%d\n", t);
  return 0;
}
