#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const int mod = 1e9 + 7;
char s[100005];
int sum[100005];
bool ok[100005];
long long dp[100005];
int main() {
  int n, m;
  scanf("%d%s%d", &n, s, &m);
  int a[2], b[2];
  a[0] = a[1] = b[0] = b[1] = INF;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'a')
      a[i & 1] = i;
    else if (s[i] == 'b')
      b[i & 1] = i;
    if (i > n - m) continue;
    if (a[(i & 1) ^ 1] < i + m) continue;
    if (b[(i & 1)] < i + m) continue;
    ok[i] = 1;
  }
  sum[0] = (s[0] == '?' ? 1 : 0);
  for (int i = 1; i < n; i++) {
    sum[i] = sum[i - 1];
    if (s[i] == '?') sum[i]++;
  }
  int cur = 0, cnt = 0;
  while (cur < n) {
    if (ok[cur])
      cur = cur + m, cnt++;
    else
      cur++;
  }
  for (int i = n - m; i >= 0; i--) {
    dp[i] = dp[i + 1];
    if (ok[i])
      dp[i] = max(dp[i], dp[i + m] + n + 1 - sum[i + m - 1] + sum[i] -
                             (s[i] == '?' ? 1 : 0));
  }
  printf("%lld\n", (long long)cnt * (n + 1) - dp[0]);
  return 0;
}
