#include <bits/stdc++.h>
using namespace std;
long long n, ans, r[200003][2], pre[200003], m;
string second;
pair<long long, long long> dp[200003];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  cin >> second;
  cin >> m;
  second = "$" + second;
  for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + (second[i] == '?');
  for (int i = n; i >= 1; i--) {
    if (i >= n - 1) {
      if (second[i] == '?') {
        r[i][0] = r[i][1] = 1;
        continue;
      }
      if (second[i] == 'a')
        r[i][0] = 1;
      else
        r[i][1] = 1;
      continue;
    }
    if (second[i] == '?') {
      r[i][0] = r[i + 2][0] + 1;
      r[i][1] = r[i + 2][1] + 1;
      continue;
    }
    if (second[i + 2] == '?') {
      if (second[i] == 'a')
        r[i][0] = r[i + 2][0] + 1;
      else
        r[i][1] = r[i + 2][1] + 1;
      continue;
    }
    if (second[i] == second[i + 2]) {
      if (second[i] == 'a')
        r[i][0] = r[i + 2][0] + 1;
      else
        r[i][1] = r[i + 2][1] + 1;
      continue;
    }
    if (second[i] == 'a')
      r[i][0] = 1;
    else
      r[i][1] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (dp[i].first == dp[i - 1].first) {
      dp[i].second = min(dp[i - 1].second, dp[i].second);
    }
    if (dp[i - 1].first > dp[i].first) dp[i] = dp[i - 1];
    if (r[i][0] >= (m + 1) / 2 && r[i + 1][1] >= m / 2) {
      if (dp[i - 1].first + 1 > dp[i + m - 1].first) {
        dp[i + m - 1].first = dp[i - 1].first + 1;
        dp[i + m - 1].second = pre[i + m - 1] - pre[i - 1] + dp[i - 1].second;
      }
    }
  }
  cout << dp[n].second << '\n';
  return 0;
}
