#include <bits/stdc++.h>
using namespace std;
const int MAXN = 123456;
const long long INF = 0x3f3f3f3f;
int n, t;
string s;
struct BITree {
  long long freq[MAXN + 1];
  BITree() { memset(freq, 0, sizeof freq); }
  void insert(int x, long long cnt = 1) {
    for (; x <= MAXN; x += x & -x) freq[x] += cnt;
  }
  long long query(int x) {
    x++;
    long long sum = 0;
    for (; x; x -= x & -x) sum += freq[x];
    return sum;
  }
  void insert_range(int xl, int xr, long long cnt = 1) {
    if (xl > xr) return;
    if (xr < 0) return;
    xl = max(xl, 0);
    xl++, xr++;
    insert(xl, cnt);
    insert(xr + 1, -cnt);
  }
  long long query_range(int xl, int xr) { return query(xr) - query(xl - 1); }
  void printree() {
    for (int i = 0; i < n; i++) cout << query(i) << " ";
    cout << endl;
  }
} even, odd;
long long mem1[123456], mem2[123456];
void maxdp(int i) {
  if (mem1[i] != -1) return;
  if (i > n - t) {
    mem1[i] = mem2[i] = 0;
    return;
  }
  maxdp(i + 1);
  pair<long long, long long> p = {mem1[i + 1], mem2[i + 1]};
  mem1[i] = p.first;
  mem2[i] = p.second;
  long long cost = (i % 2 == 0 ? even.query(i) : odd.query(i));
  maxdp(i + t);
  pair<long long, long long> q = {1 + mem1[i + t], mem2[i + t] - cost};
  if (cost >= 0 && p < q) {
    mem1[i] = q.first;
    mem2[i] = q.second;
  }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n >> s >> t;
  int na = (t + 1) / 2, nb = t / 2;
  int ar = 0, al = ar - 2 * (na - 1);
  int br = -1, bl = br - 2 * (nb - 1);
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      if (s[i] == '?') {
        even.insert_range(i + al, i + ar);
        odd.insert_range(i + bl, i + br);
      }
      if (s[i] == 'a') {
        odd.insert_range(i + bl, i + br, -INF);
      }
      if (s[i] == 'b') {
        even.insert_range(i + al, i + ar, -INF);
      }
    } else {
      if (s[i] == '?') {
        odd.insert_range(i + al, i + ar);
        even.insert_range(i + bl, i + br);
      }
      if (s[i] == 'a') {
        even.insert_range(i + bl, i + br, -INF);
      }
      if (s[i] == 'b') {
        odd.insert_range(i + al, i + ar, -INF);
      }
    }
  }
  memset(mem1, -1, sizeof mem1);
  maxdp(0);
  cout << -mem2[0] << endl;
}
