#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long N = 3e5 + 10;
const long long big = 1e14;
const long long block = 500;
const long long mod = 1e9 + 7;
long long n;
string a;
long long b;
long long dp[N], p[N];
pair<long long, long long> dp2[N];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> a >> b;
  string second = "ab";
  a = "$" + a;
  for (int i = 1; i <= n; i++) p[i] = p[i - 1] + (a[i] == '?');
  for (int i = n; i > 0; i--) {
    string first = a.substr(i, min(n - i + 1, 2ll));
    bool x = 1;
    for (int j = 0; j < first.size(); j++)
      x &= (first[j] == second[j] || first[j] == '?');
    if (x == 0)
      dp[i] = (first[0] == 'a' || first[0] == '?');
    else
      dp[i] = dp[i + 2] + first.size();
  }
  pair<long long, long long> mx = {0, 0};
  for (int i = b; i <= n; i++) {
    long long z = dp[i - b + 1];
    dp2[i] = mx;
    if (z >= b) {
      pair<long long, long long> first = dp2[i - b];
      first.first++, first.second -= p[i] - p[i - b];
      dp2[i] = max(dp2[i], first);
    }
    mx = max(dp2[i], mx);
  }
  cout << -dp2[n].second;
}
