#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool uin(T &a, T b) {
  return a > b && (a = b, true);
}
template <class T>
inline bool uax(T &a, T b) {
  return a < b && (a = b, true);
}
class EMaximumQuestions {
  int N, M;
  string S;

 public:
  void solve_case(istream &cin, ostream &cout) {
    cin >> N >> S >> M;
    vector<vector<int>> len(2, vector<int>(N + 1));
    vector<pair<int, int>> dp(N + 1);
    vector<int> cnt(N + 1);
    for (int i = 0; i < N; ++i) {
      cnt[i + 1] = cnt[i];
      if (S[i] == '?') {
        ++cnt[i + 1];
        len[0][i + 1] = len[1][i] + 1;
        len[1][i + 1] = len[0][i] + 1;
      } else if (S[i] == 'a') {
        len[0][i + 1] = len[1][i] + 1;
      } else {
        len[1][i + 1] = len[0][i] + 1;
      }
      dp[i + 1] = dp[i];
      if (i + 1 >= M && len[1 ^ (M % 2)][i + 1] >= M) {
        int cnt_between = cnt[i + 1] - cnt[i + 1 - M];
        uax(dp[i + 1], make_pair(dp[i + 1 - M].first + 1,
                                 dp[i + 1 - M].second - cnt_between));
      }
    }
    cout << -dp[N].second << '\n';
  }
  void solve(istream &cin, ostream &cout) {
    int tt = 1;
    while (tt--) solve_case(cin, cout);
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  EMaximumQuestions solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}
