#include <bits/stdc++.h>
using namespace std;
void scanint(int &x) {
  register int c = getchar();
  bool flag = false;
  x = 0;
  for (; ((c < 48 && c != 45) || c > 57); c = getchar())
    ;
  if (c == 45) {
    flag = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (flag) x = x - (x << 1);
  return;
}
void scanll(long long &x) {
  register long long c;
  bool flag = false;
  x = 0;
  for (; ((c < 48 && c != 45) || c > 57); c = getchar())
    ;
  if (c == 45) {
    flag = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (flag) x = x - (x << 1);
  return;
}
const int N = 100005;
int odd[3], ev[3];
pair<int, int> dp[N];
int temp[3];
bool check(int m) {
  if (ev[0] || odd[1]) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int m;
  cin >> m;
  if (m > n) {
    cout << "0\n";
    return 0;
  }
  for (int i = 0; i < m; i++) {
    if (i % 2 == 0) {
      if (s[i] == 'a')
        odd[0]++;
      else if (s[i] == 'b')
        odd[1]++;
      else
        odd[2]++;
    } else {
      if (s[i] == 'a')
        ev[0]++;
      else if (s[i] == 'b')
        ev[1]++;
      else
        ev[2]++;
    }
  }
  dp[m - 1] = make_pair(0, 0);
  if (check(m)) dp[m - 1] = make_pair(1, odd[2] + ev[2]);
  pair<int, int> last = dp[0];
  for (int i = m; i < s.size(); i++) {
    if (s[i - m] == 'a')
      odd[0]--;
    else if (s[i - m] == 'b')
      odd[1]--;
    else
      odd[2]--;
    for (int j = 0; j < 3; j++) {
      temp[j] = ev[j];
      ev[j] = odd[j];
      odd[j] = temp[j];
    }
    if (m & 1) {
      if (s[i] == 'a')
        odd[0]++;
      else if (s[i] == 'b')
        odd[1]++;
      else
        odd[2]++;
    } else {
      if (s[i] == 'a')
        ev[0]++;
      else if (s[i] == 'b')
        ev[1]++;
      else
        ev[2]++;
    }
    dp[i] = dp[i - 1];
    if (check(m)) {
      if ((last.first + 1) > dp[i].first)
        dp[i] = make_pair(last.first + 1, last.second + odd[2] + ev[2]);
      else if ((last.first + 1) == dp[i].first)
        dp[i].second = min(last.second + odd[2] + ev[2], dp[i].second);
    }
    if (dp[i - m + 1].first > last.first)
      last = dp[i - m + 1];
    else if (dp[i - m + 1].first == last.first)
      last.second = min(last.second, dp[i - m + 1].second);
  }
  cout << dp[n - 1].second << "\n";
  return 0;
}
