#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int INF = 0x3f3f3f3f;
template <class T>
inline bool RD(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1, ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
template <class T>
inline void PT(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) PT(x / 10);
  putchar(x % 10 + '0');
}
const int N = 1e5 + 100;
char s[N];
int f[2][N], sum[N];
pair<int, int> dp[N];
int main() {
  int n;
  cin >> n;
  scanf("%s", s + 1);
  int tot = 0;
  for (int i = n; i >= 1; i--) {
    if (s[i] == '?') {
      sum[i] = sum[i + 1] + 1;
      f[0][i] = f[1][i + 1] + 1;
      f[1][i] = f[0][i + 1] + 1;
    } else {
      f[s[i] - 'a'][i] = f[(s[i] - 'a') ^ 1][i + 1] + 1;
      f[(s[i] - 'a') ^ 1][i] = 0;
      sum[i] = sum[i + 1];
    }
  }
  int m;
  cin >> m;
  memset(dp, 0x3f, sizeof(dp));
  dp[1] = pair<int, int>(0, 0);
  for (int i = 1; i <= n; i++) {
    if (dp[i + 1] > dp[i]) dp[i + 1] = dp[i];
    int now = s[i] != '?' ? s[i] - 'a' : 0;
    if (now == 0 && f[now][i] >= m) {
      dp[i + m] = min(
          dp[i + m],
          pair<int, int>(dp[i].first - 1, dp[i].second + sum[i] - sum[i + m]));
    }
  }
  printf("%d\n", dp[n + 1].second);
}
