#include <bits/stdc++.h>
using namespace std;
const long long maxn = 5e5 + 7;
const long long mod = 1e9 + 7;
const long long INF = 1e9 + 7;
const long long mlog = 20;
const long long SQ = 400;
long long ps[maxn];
pair<long long, long long> dp[maxn];
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(), cout.tie();
  ;
  long long n;
  cin >> n;
  string s;
  cin >> s;
  ps[0] = (s[0] == '?' ? 1 : 0);
  for (long long i = 1; i < n; i++) ps[i] = ps[i - 1] + (s[i] == '?' ? 1 : 0);
  ps[n] = ps[n - 1];
  long long m;
  cin >> m;
  long long la[2] = {-1, -1};
  long long lb[2] = {-1, -1};
  for (long long i = 0; i < n; i++) {
    if (s[i] == 'a') la[i % 2] = i;
    if (s[i] == 'b') lb[i % 2] = i;
    long long st = i - m + 1;
    dp[i + 1] = dp[i];
    if (st < 0) continue;
    if (lb[st % 2] <= st - 1 && la[(st + 1) % 2] <= st - 1)
      dp[i + 1] = max(
          dp[i + 1],
          make_pair(dp[st].first + 1, -(-dp[st].second + ps[i] - ps[st - 1])));
  }
  cout << -dp[n].second << "\n";
  return 0;
}
