#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long inf = numeric_limits<long long>::max() / 2;
const long double eps = 1e-9;
const long double pi = acos(-1);
template <typename T>
inline bool mineq(T& a, T b) {
  return (a > b) ? (a = b, 1) : 0;
}
template <typename T>
inline bool maxeq(T& a, T b) {
  return (a < b) ? (a = b, 1) : 0;
}
inline void solve(), read();
const string file = "";
int main() {
  if (file != "") {
    freopen((file + ".in").c_str(), "r", stdin);
    freopen((file + ".out").c_str(), "w", stdout);
  }
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  read();
  solve();
  return 0;
}
pair<long long, long long> operator+(pair<long long, long long> a,
                                     pair<long long, long long> b) {
  return {a.first + b.first, a.second + b.second};
}
long long n, m;
string s;
vector<long long> good, qu;
vector<vector<long long> > f;
vector<pair<long long, long long> > dp;
void precalc() {
  f.assign(n + 2, vector<long long>(2, 0));
  if (s[n] == 'a') {
    f[n][0] = 1;
  } else if (s[n] == 'b') {
    f[n][1] = 1;
  } else {
    f[n][0] = f[n][1] = 1;
  }
  if (s[n - 1] == 'a') {
    f[n - 1][0] = 1;
  } else if (s[n - 1] == 'b') {
    f[n - 1][1] = 1;
  } else {
    f[n - 1][0] = f[n - 1][1] = 1;
  }
  for (long long i = n - 2; i > 0; i--) {
    if (s[i] == 'a') {
      f[i][0] = f[i + 2][0] + 1;
      f[i][1] = 0;
    } else if (s[i] == 'b') {
      f[i][0] = 0;
      f[i][1] = f[i + 2][1] + 1;
    } else {
      f[i][0] = f[i + 2][0] + 1;
      f[i][1] = f[i + 2][1] + 1;
    }
  }
  good.assign(n + 1, 0);
  for (long long i = 1; i <= n; i++) {
    if (f[i][0] >= (m + 1) / 2 && f[i + 1][1] >= m / 2) {
      good[i] = 1;
    }
  }
  qu.assign(n + 1, 0);
  for (long long i = 1; i <= n; i++) {
    qu[i] = (s[i] == '?') + qu[i - 1];
  }
}
void countdp() {
  dp.resize(n + 1);
  dp[0] = {0, 0};
  pair<long long, long long> cur = dp[0];
  for (long long i = 1; i + m - 1 <= n; i++) {
    mineq(dp[i], dp[i - 1]);
    if (!good[i]) {
      continue;
    }
    pair<long long, long long> cost = {-1, qu[i + m - 1] - qu[i - 1]};
    dp[i + m - 1] = dp[i - 1] + cost;
    mineq(cur, dp[i]);
  }
  pair<long long, long long> ans = *min_element((dp).begin(), (dp).end());
  cout << ans.second << "\n";
}
inline void solve() {
  precalc();
  countdp();
}
inline void read() {
  cin >> n >> s >> m;
  s.insert(s.begin(), 0);
}
