#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, dp[N], ans[N], psum[N], last[N][2][2];
string s;
bool check(int indx) {
  return (last[indx][!(m & 1)][!(indx & 1)] <= indx - m) &&
         (last[indx][m & 1][indx & 1] <= indx - m);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++) last[i][j][k] = -1;
  cin >> n >> s >> m;
  for (int i = 1; i <= n; i++) psum[i] = psum[i - 1] + (s[i - 1] == '?');
  if (s[0] != '?') last[0][s[0] - 'a'][0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++) last[i][j][k] = last[i - 1][j][k];
    if (s[i] != '?') last[i][s[i] - 'a'][i & 1] = i;
  }
  dp[m - 1] = check(m - 1);
  for (int i = m; i < n; i++) {
    dp[i] = dp[i - 1];
    if (check(i)) dp[i] = max(dp[i], 1 + dp[i - m]);
  }
  memset(ans, -1, sizeof ans);
  for (int i = 0; i < m; i++) ans[i] = 0;
  if (dp[m - 1]) ans[m - 1] = psum[m];
  for (int i = m; i < n; i++) {
    if (check(i) && dp[i] == 1 + dp[i - m])
      ans[i] = psum[i + 1] - psum[i - m + 1] + ans[i - m];
    if (dp[i] == dp[i - 1]) {
      if (ans[i] == -1)
        ans[i] = ans[i - 1];
      else
        ans[i] = min(ans[i], ans[i - 1]);
    }
    if (ans[i] == -1) ans[i] = 0;
  }
  cout << ans[n - 1];
}
