#include <bits/stdc++.h>
using namespace std;
int N, M;
char S[100005];
int Partial[2][100005], P2[100005];
pair<int, int> P[100005];
int cnt;
int Cost[100005];
pair<int, int> DP[100005];
int binS(int first) {
  int left = 1, right = cnt, sol = 0, mid;
  while (left <= right) {
    mid = (left + right) / 2;
    if (P[mid].second < first) {
      sol = mid;
      left = mid + 1;
    } else
      right = mid - 1;
  }
  return sol;
}
void Read() {
  cin >> N;
  cin.get();
  cin.getline(S + 1, 100005);
  cin >> M;
  for (int i = 1; i <= N; i++) {
    int add1 = 0, add2 = 0;
    if (i >= 2) add1 = Partial[0][i - 2], add2 = Partial[1][i - 2];
    Partial[0][i] = add1;
    Partial[1][i] = add2;
    if (S[i] != '?') Partial[S[i] - 'a'][i]++;
    P2[i] = P2[i - 1];
    if (S[i] == '?') P2[i]++;
  }
}
bool Good(int x) {
  if (x + M - 1 > N) return 0;
  int last = x + M - 1;
  int nb = (M + 1) / 2 - 1;
  if (Partial[1][x + 2 * nb] - Partial[1][max(0, x - 2)] > 0) return 0;
  nb = M - (M + 1) / 2 - 1;
  if (Partial[0][x + 1 + 2 * nb] - Partial[0][max(0, x - 1)] > 0) return 0;
  return 1;
}
void precalcInt() {
  for (int i = 1; i <= N; i++) {
    if (Good(i)) {
      P[++cnt] = make_pair(i, i + M - 1);
      Cost[cnt] = P2[i + M - 1] - P2[i - 1];
    }
  }
  for (int i = 1; i <= cnt; i++) {
    int p = binS(P[i].first);
    DP[i].first = DP[p].first + 1;
    DP[i].second = DP[p].second + Cost[i];
    if (DP[i].first < DP[i - 1].first ||
        (DP[i].first == DP[i - 1].first && DP[i].second > DP[i - 1].second))
      DP[i] = DP[i - 1];
  }
  cout << DP[cnt].second << "\n";
}
int main() {
  Read();
  precalcInt();
  return 0;
}
