#include <bits/stdc++.h>
using namespace std;
int a[2][100010], b[100010], c[100010], dp[2][100010];
int main() {
  int n, m;
  cin >> n;
  char temp;
  cin.get();
  for (int i = 2; i <= n + 1; i++) {
    temp = cin.get();
    c[i] = c[i - 1];
    a[0][i] = a[0][i - 2];
    a[1][i] = a[1][i - 2];
    if (temp == '?')
      a[0][i]++, a[1][i]++, c[i]++;
    else
      a[temp - 97][i]++;
  }
  cin >> m;
  int f = m / 2;
  int ff = m - f;
  for (int i = 1; i <= n - m + 1; i++)
    if ((a[0][i - 1 + 2 * ff] - a[0][i - 1] == ff) &&
        (a[1][i + 2 * f] - a[1][i] == f))
      b[i] = c[i + m] - c[i];
    else
      b[i] = -1;
  for (int i = n - m + 1; i >= 1; i--) {
    if (b[i] == -1)
      dp[0][i] = dp[0][i + 1], dp[1][i] = dp[1][i + 1];
    else if (dp[0][i + m] + 1 == dp[0][i + 1])
      dp[0][i] = dp[0][i + 1],
      dp[1][i] = (dp[1][i + m] + b[i] < dp[1][i + 1] ? dp[1][i + m] + b[i]
                                                     : dp[1][i + 1]);
    else if (dp[0][i + m] + 1 > dp[0][i + 1])
      dp[0][i] = dp[0][i + m] + 1, dp[1][i] = dp[1][i + m] + b[i];
    else
      dp[0][i] = dp[0][i + 1], dp[1][i] = dp[1][i + 1];
  }
  cout << dp[1][1];
  return 0;
}
