#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e7;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;
pair<int, int> get(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) {
    return a;
  } else if (a.first < b.first) {
    return b;
  }
  if (a.second < b.second) {
    return a;
  }
  return b;
}
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int t;
  cin >> t;
  vector<pair<int, int>> dp(n + 1);
  vector<int> cnt(n + 1);
  vector<int> odd_bad(n + 1);
  vector<int> even_bad(n + 1);
  for (int i = 0; i < n; ++i) {
    cnt[i + 1] = cnt[i] + (s[i] == '?');
    odd_bad[i + 1] = odd_bad[i];
    even_bad[i + 1] = even_bad[i];
    if (s[i] == 'a') {
      if (i % 2 == 0) {
        odd_bad[i + 1] += 1;
      } else {
        even_bad[i + 1] += 1;
      }
    } else if (s[i] == 'b') {
      if (i % 2 == 1) {
        odd_bad[i + 1] += 1;
      } else {
        even_bad[i + 1] += 1;
      }
    }
  }
  for (int i = t; i <= n; ++i) {
    dp[i] = get(dp[i], dp[i - 1]);
    int now = 0;
    int to_replace = cnt[i] - cnt[i - t];
    int sp = i - t;
    bool fail = false;
    if (sp % 2 == 0) {
      if (even_bad[i] - even_bad[sp]) {
        fail = true;
      }
    } else {
      if (odd_bad[i] - odd_bad[sp]) {
        fail = true;
      }
    }
    if (!fail) {
      pair<int, int> now = dp[i - t];
      now.first += 1;
      now.second += to_replace;
      dp[i] = get(dp[i], now);
    }
  }
  cout << dp[n].second << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
