#include <bits/stdc++.h>
using namespace std;
const int Inf = (int)1e9 + 7;
const long long LongInf = (long long)1e18 + 7;
namespace {
const int N = (int)1e5 + 7;
int n;
string s;
int m;
pair<int, int> dp[2 * N];
int even_a[N], odd_a[N];
int even_b[N], odd_b[N];
int q[N];
void solve() {
  cin >> n;
  cin >> s;
  cin >> m;
  for (int i = 0; i < n; i++) {
    even_a[i + 1] = even_a[i] + (i % 2 == 0 && s[i] == 'a' ? 1 : 0);
    even_b[i + 1] = even_b[i] + (i % 2 == 0 && s[i] == 'b' ? 1 : 0);
    odd_a[i + 1] = odd_a[i] + (i % 2 == 1 && s[i] == 'a' ? 1 : 0);
    odd_b[i + 1] = odd_b[i] + (i % 2 == 1 && s[i] == 'b' ? 1 : 0);
    q[i + 1] = q[i] + (s[i] == '?' ? 1 : 0);
  }
  for (int i = 0; i < 2 * N; i++) dp[i] = pair<int, int>(0, 0);
  for (int i = 0; i < n; i++) {
    if (dp[i + 1].first < dp[i].first)
      dp[i + 1] = dp[i];
    else if (dp[i + 1].first == dp[i].first && dp[i].second < dp[i + 1].second)
      dp[i + 1] = dp[i];
    int j = i + m;
    int hit_a = (i % 2 == 0 ? even_a[j] - even_a[i] : odd_a[j] - odd_a[i]);
    int hit_b = (i % 2 == 0 ? odd_b[j] - odd_b[i] : even_b[j] - even_b[i]);
    int nq = q[j] - q[i];
    if (hit_a + hit_b + nq == m) {
      if (dp[i].first + 1 > dp[i + m].first) {
        dp[i + m].first = dp[i].first + 1;
        dp[i + m].second = dp[i].second + nq;
      } else if (dp[i].first + 1 == dp[i + m].first) {
        if (dp[i].second + nq < dp[i + m].second)
          dp[i + m].second = dp[i].second + nq;
      }
    }
  }
  int bmax = 0, rmin = Inf;
  for (int i = 0; i < 2 * N; i++) bmax = max(bmax, dp[i].first);
  for (int i = 0; i < 2 * N; i++)
    if (dp[i].first == bmax) rmin = min(rmin, dp[i].second);
  cout << rmin << "\n";
}
}  // namespace
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(9);
  cout << fixed;
  solve();
  return 0;
}
