#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '{';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << "  " << H;
  dbg_out(T...);
}
const int N = 1e5 + 5;
int n, m, cnt_ques[N], a_rght[N][3], b_rght[N][3], cost[N];
string s;
bool vis[N];
pair<int, int> mx_beauty[N];
void precalc() {
  int ques = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '?') {
      ques++;
    }
    cnt_ques[i] = ques;
  }
  int a_last[] = {n, n}, b_last[] = {n, n};
  a_rght[n][0] = a_rght[n][1] = b_rght[n][0] = b_rght[n][1] = n;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'a') {
      b_last[i % 2] = i;
    } else if (s[i] == 'b') {
      a_last[i % 2] = i;
    }
    a_rght[i][i % 2] = a_last[i % 2];
    b_rght[i][i % 2] = b_last[i % 2];
    cost[i] = -1;
    if (n - i >= m) {
      int end = min(a_rght[i][i % 2], b_rght[i + 1][(i + 1) % 2]) - 1;
      if (end - i + 1 >= m) {
        end = i + m - 1;
        cost[i] = cnt_ques[end] - (i != 0 ? cnt_ques[i - 1] : 0);
      }
    }
  }
}
pair<int, int> calc(int at) {
  if (n - at < m) {
    return {0, 0};
  }
  if (vis[at] == true) {
    return mx_beauty[at];
  }
  pair<int, int> mx = calc(at + 1);
  if (cost[at] != -1) {
    auto rem_beauty = calc(at + m);
    mx = max(mx, {rem_beauty.first + 1, -cost[at] + rem_beauty.second});
  }
  vis[at] = true;
  return mx_beauty[at] = mx;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  cin >> n >> s >> m;
  precalc();
  cout << -calc(0).second << '\n';
}
