#include <bits/stdc++.h>
using namespace std;
int n, m, sumBpar[101010], sumApar[101010], sumBimpar[101010],
    sumAimpar[101010], quest[101010];
pair<int, int> dp[101010];
string s;
pair<int, int> melhor(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) return a;
  if (b.first > a.first) return b;
  return pair<int, int>(a.first, min(a.second, b.second));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  cin >> s;
  cin >> m;
  for (int i = 0; i < n; i++) {
    sumApar[i] = sumApar[i - 1] + (s[i] == 'a' && i % 2 == 0);
    sumAimpar[i] = sumAimpar[i - 1] + (s[i] == 'a' && i % 2 == 1);
    sumBpar[i] = sumBpar[i - 1] + (s[i] == 'b' && i % 2 == 0);
    sumBimpar[i] = sumBimpar[i - 1] + (s[i] == 'b' && i % 2 == 1);
    quest[i] = quest[i - 1] + (s[i] == '?');
  }
  bool impar = (m % 2);
  for (int i = 0; i < m - 1; i++) dp[i] = pair<int, int>(0, 0);
  pair<int, int> acc;
  acc = pair<int, int>(0, 0);
  for (int i = m - 1; i < n; i++) {
    if (i >= m) acc = melhor(acc, dp[i - m]);
    if (impar) {
      int sa, sb, sq;
      if (i % 2 == 0)
        sa = sumAimpar[i] - ((i - m >= 0) ? sumAimpar[i - m] : 0);
      else if (i % 2)
        sa = sumApar[i] - ((i - m >= 0) ? sumApar[i - m] : 0);
      if (i % 2)
        sb = sumBimpar[i] - ((i - m >= 0) ? sumBimpar[i - m] : 0);
      else if (i % 2 == 0)
        sb = sumBpar[i] - ((i - m >= 0) ? sumBpar[i - m] : 0);
      sq = quest[i] - ((i - m >= 0) ? quest[i - m] : 0);
      if (sa == 0 && sb == 0) {
        dp[i] = pair<int, int>(acc.first + 1, acc.second + sq);
      }
    } else {
      int sa, sb, sq;
      if (i % 2 == 0)
        sb = sumBimpar[i] - ((i - m >= 0) ? sumBimpar[i - m] : 0);
      else if (i % 2)
        sb = sumBpar[i] - ((i - m >= 0) ? sumBpar[i - m] : 0);
      if (i % 2)
        sa = sumAimpar[i] - ((i - m >= 0) ? sumAimpar[i - m] : 0);
      else if (i % 2 == 0)
        sa = sumApar[i] - ((i - m >= 0) ? sumApar[i - m] : 0);
      sq = quest[i] - ((i - m >= 0) ? quest[i - m] : 0);
      if (sa == 0 && sb == 0) {
        dp[i] = pair<int, int>(acc.first + 1, acc.second + sq);
      }
    }
  }
  acc = pair<int, int>(0, 0);
  for (int i = 0; i < n; i++) {
    acc = melhor(acc, dp[i]);
  }
  cout << acc.second << endl;
}
