#include <bits/stdc++.h>
using namespace std;
void rd(long long &x) { scanf("%lld", &x); }
void rd(long long &x, long long &y) { scanf("%lld%lld", &x, &y); }
void rd(long long &x, long long &y, long long &z) {
  scanf("%lld%lld%lld", &x, &y, &z);
}
void rd(long long &x, long long &y, long long &z, long long &s) {
  scanf("%lld%lld%lld%lld", &x, &y, &z, &s);
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
void faltu() { cerr << endl; }
template <typename T>
void faltu(T a[], int n) {
  for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
  cerr << endl;
}
template <typename T, typename... hello>
void faltu(T arg, const hello &...rest) {
  cerr << arg << ' ';
  faltu(rest...);
}
string s;
const long long N = 2e5 + 5;
long long n, m, cnt[N], mx[N][2];
bool visit[N];
pair<long long, long long> dp[N];
pair<long long, long long> back(long long pos) {
  if (pos >= n) return make_pair(0LL, 0LL);
  if (visit[pos]) return dp[pos];
  visit[pos] = 1;
  pair<long long, long long> &r = dp[pos];
  r = back(pos + 1);
  if (mx[pos][0] == m) {
    pair<long long, long long> q = back(pos + m);
    q.first++;
    q.second += cnt[pos + m - 1];
    if (pos) q.second -= cnt[pos - 1];
    if (q.first > r.first || (q.first == r.first && q.second < r.second)) r = q;
  }
  return r;
}
int main() {
  rd(n);
  cin >> s;
  rd(m);
  for (long long i = 0; i < (n); i++) {
    cnt[i] = (s[i] == '?');
    if (i) cnt[i] += cnt[i - 1];
  }
  for (int i = n; i < N; i++) cnt[i] = cnt[i - 1];
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'a') {
      mx[i][0] = min(mx[i + 1][1] + 1, m);
      mx[i][1] = 0;
    } else if (s[i] == 'b') {
      mx[i][1] = min(mx[i + 1][0] + 1, m);
      mx[i][0] = 0;
    } else {
      mx[i][0] = min(mx[i + 1][1] + 1, m);
      mx[i][1] = min(mx[i + 1][0] + 1, m);
    }
  }
  pair<long long, long long> p = back(0);
  cout << (long long)p.second;
  return 0;
}
