#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-12;
const int MOD = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e5 + 4;
const int maxm = 1e4 + 4;
inline long long rule(long long x) { return (x %= MOD) += x < 0 ? MOD : 0; }
char s[maxn];
int to[2][maxn];
int sum[maxn], add[maxn];
int query(int l, int r) {
  if (l != 0) return sum[r] - sum[l - 1];
  return sum[r];
}
int dp[maxn];
int main() {
  int ik, i, j, k, kase;
  int n, m;
  scanf("%d", &n);
  scanf("%s", s);
  for (int i = n - 1; i > -1; --i) {
    if (s[i] == 'b')
      to[0][i] = -1;
    else {
      if (s[i + 2] != 'b' && s[i + 2])
        to[0][i] = to[0][i + 2];
      else
        to[0][i] = i;
    }
    if (s[i] == 'a')
      to[1][i] = -1;
    else {
      if (s[i + 2] != 'a' && s[i + 2])
        to[1][i] = to[1][i + 2];
      else
        to[1][i] = i;
    }
    sum[i] = s[i] == '?' ? 1 : 0;
  }
  for (int i = 1; i < n; ++i) sum[i] += sum[i - 1];
  scanf("%d", &m);
  for (int i = 0; i < n; ++i) {
    if (dp[i + 1] < dp[i]) {
      dp[i + 1] = dp[i];
      add[i + 1] = add[i];
    } else if (dp[i + 1] == dp[i] && add[i + 1] > add[i])
      add[i + 1] = add[i];
    int lst = i + m - 1, lsta, lstb;
    if (lst >= n) continue;
    if (m & 1)
      lsta = lst;
    else
      lsta = lst - 1;
    if (to[0][i] < lsta) continue;
    if (m != 1) {
      if (m & 1)
        lstb = lst - 1;
      else
        lstb = lst;
      if (to[1][i + 1] < lstb) continue;
    }
    int a = query(i, lst);
    if (dp[lst + 1] < dp[i] + 1) {
      dp[lst + 1] = dp[i] + 1;
      add[lst + 1] = add[i] + a;
    }
  }
  cout << add[n] << endl;
  return 0;
}
