#include <bits/stdc++.h>
using namespace std;
string S;
int even[100005], qMark[100005];
int dp[100005], preMax[100005], changes[100005], preMin[100005];
int main() {
  int N, M;
  cin >> N >> S >> M;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'a') {
      if (i % 2 == 0)
        even[i] = 1;
      else
        even[i] = -1;
    } else if (S[i] == 'b') {
      if (i % 2)
        even[i] = 1;
      else
        even[i] = -1;
    } else
      qMark[i] = 1;
    even[i] += even[i - 1];
    qMark[i] += qMark[i - 1];
  }
  int ans = 0, changeMin = 0;
  for (int i = M - 1; i < N; i++) {
    int sum = even[i] - even[i - M];
    sum = (sum * ((i - M + 1) % 2 == 0 ? 1 : -1)) + qMark[i] - qMark[i - M];
    if (sum == M) {
      dp[i] = 1 + preMax[i - M];
      changes[i] = qMark[i] - qMark[i - M] + preMin[i - M];
    }
    preMax[i] = preMax[i - 1], preMin[i] = preMin[i - 1];
    if (dp[i] > preMax[i])
      preMax[i] = ans = dp[i], preMin[i] = changeMin = changes[i];
    else if (dp[i] == preMax[i])
      preMin[i] = changeMin = min(changes[i], preMin[i]);
  }
  printf("%d\n", changeMin);
  return 0;
}
