#include <bits/stdc++.h>
using namespace std;
long long int n, m;
string s;
long long int cnt_qstn[100003];
bool chk[100003];
array<long long int, 2> dp[100003];
long long int cur_a[100003];
long long int cur_b[100003];
array<long long int, 2> go(long long int pos) {
  if (pos + m - 1ll >= n) {
    return {0, 0};
  }
  if (dp[pos][0] != -1) {
    return dp[pos];
  }
  array<long long int, 2> op1 = go(pos + 1ll);
  array<long long int, 2> op2 = {0, 0};
  if (chk[pos]) {
    op2 = go(pos + m);
    op2[0] += 1ll;
    op2[1] += cnt_qstn[pos];
  }
  if (op1[0] > op2[0]) {
    return dp[pos] = op1;
  } else if (op1[0] < op2[0]) {
    return dp[pos] = op2;
  } else {
    return dp[pos] = {op1[0], min(op1[1], op2[1])};
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> s >> m;
  long long int cur = 0;
  for (long long int i = n - 1ll; i >= 0; i--) {
    if (s[i] == '?') {
      cur++;
    }
    if (i + m < n && s[i + m] == '?') {
      cur--;
    }
    cnt_qstn[i] = cur;
    dp[i] = {-1, 0};
  }
  cur = 0;
  for (long long int i = n - 1ll; i >= 0; i -= 2ll) {
    if (s[i] == 'b') {
      cur++;
    }
    long long int next = i;
    next += ((m + 1ll) / 2ll) * 2ll;
    if (next < n && s[next] == 'b') {
      cur--;
    }
    cur_b[i] = cur;
  }
  cur = 0;
  for (long long int i = n - 2ll; i >= 0; i -= 2ll) {
    if (s[i] == 'b') {
      cur++;
    }
    long long int next = i;
    next += ((m + 1ll) / 2ll) * 2ll;
    if (next < n && s[next] == 'b') {
      cur--;
    }
    cur_b[i] = cur;
  }
  cur = 0;
  for (long long int i = n - 1ll; i >= 0; i -= 2ll) {
    if (s[i] == 'a') {
      cur++;
    }
    long long int next = i;
    next += (m / 2ll) * 2ll;
    if (next < n && s[next] == 'a') {
      cur--;
    }
    cur_a[i] = cur;
  }
  cur = 0;
  for (long long int i = n - 2ll; i >= 0; i -= 2ll) {
    if (s[i] == 'a') {
      cur++;
    }
    long long int next = i;
    next += (m / 2ll) * 2ll;
    if (next < n && s[next] == 'a') {
      cur--;
    }
    cur_a[i] = cur;
  }
  for (long long int i = 0; i < n; i++) {
    if (i + m - 1ll < n && cur_b[i] == 0) {
      if (m == 1) {
        chk[i] = 1;
      } else if (m != 1 && cur_a[i + 1ll] == 0) {
        chk[i] = 1;
      }
    }
  }
  auto res = go(0);
  cout << res[1] << "\n";
}
