#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 10;
pair<int, int> dp[MAX];
int to[MAX], n;
int acc[MAX];
int get(int l, int r) {
  if (l == 0) return acc[r];
  return acc[r] - acc[l - 1];
}
pair<int, int> go(int i) {
  if (i >= n) return pair<int, int>(0, -0);
  pair<int, int> &r = dp[i];
  if (r == pair<int, int>(-1, -1)) {
    r = pair<int, int>(-INT_MAX, -INT_MAX);
    r = max(r, go(i + 1));
    if (to[i] != n + 1) {
      pair<int, int> t = go(to[i]);
      t.first += 1;
      t.second -= get(i, to[i] - 1);
      r = max(r, t);
    }
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  string s;
  cin >> s;
  int m;
  cin >> m;
  string t = "";
  for (int i = 0; i < m; i++)
    if (i & 1)
      t.push_back('b');
    else
      t.push_back('a');
  for (int i = 0; i < n; i++) {
    dp[i] = pair<int, int>(-1, -1);
    if (i) acc[i] += acc[i - 1];
    acc[i] += s[i] == '?';
    to[i] = n + 1;
  }
  int letter = 0, last_match = -1;
  for (int i = 0, j = 0; i < n; i++) {
    if (j < i) letter = 0, j = i;
    if ((last_match > 0 && last_match % 2 == i % 2) || letter == 0) {
      last_match = i;
      while (j < n && (j - i) < m && (s[j] == t[j - i] || s[j] == '?')) {
        if (s[j] != '?') letter++;
        j++;
      }
    }
    if (j - i == m) {
      to[i] = j;
    }
    if (s[i] != '?') letter--;
  }
  cout << -go(0).second << '\n';
}
