#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
char s[MAXN];
int a[MAXN];
int b[MAXN];
int num[MAXN];
bool sign1[MAXN];
typedef struct Point {
  int x, y;
  bool operator<(Point p) const {
    if (x == p.x) return y > p.y;
    return x < p.x;
  }
} point;
point dp[MAXN];
int main() {
  int n, i, j;
  int m;
  scanf("%d", &n);
  scanf("%s", s);
  scanf("%d", &m);
  if (s[0] == 'a')
    a[0] = 1, b[0] = 0;
  else if (s[0] == 'b')
    a[0] = 0, b[0] = 1;
  else
    a[0] = 1, b[0] = 1;
  for (i = 1; i < n; i++) {
    if (s[i] == 'a') {
      if (s[i - 1] == 'a') {
        a[i] = 1;
      } else {
        a[i] = b[i - 1] + 1;
      }
      b[i] = 0;
    } else if (s[i] == 'b') {
      if (s[i - 1] == 'b') {
        b[i] = 1;
      } else {
        b[i] = a[i - 1] + 1;
      }
      a[i] = 0;
    } else {
      if (s[i - 1] == 'a') {
        a[i] = 1;
        b[i] = a[i - 1] + 1;
      } else if (s[i - 1] == 'b') {
        b[i] = 1;
        a[i] = b[i - 1] + 1;
      } else {
        a[i] = b[i - 1] + 1;
        b[i] = a[i - 1] + 1;
      }
    }
  }
  if (m % 2) {
    for (i = 0; i < n; i++)
      if (a[i] >= m) sign1[i] = true;
  } else {
    for (i = 0; i < n; i++)
      if (b[i] >= m) sign1[i] = true;
  }
  if (s[0] == '?') num[0] = 1;
  for (i = 1; i < n; i++) {
    num[i] = num[i - 1];
    if (s[i] == '?') num[i]++;
  }
  point tmp;
  int y;
  if (sign1[0]) {
    dp[0].x = 1;
    if (s[0] == '?')
      dp[0].y = 1;
    else
      dp[0].y = 0;
  } else
    dp[0].x = 0, dp[0].y = 0;
  for (i = 1; i < n; i++) {
    dp[i].x = dp[i - 1].x;
    dp[i].y = dp[i - 1].y;
    if (sign1[i]) {
      if (i == m - 1) {
        y = num[i];
      } else {
        y = num[i] - num[i - m];
      }
      tmp.x = dp[i - m].x + 1;
      tmp.y = dp[i - m].y + y;
      if (dp[i] < tmp) {
        dp[i].x = tmp.x;
        dp[i].y = tmp.y;
      }
    }
  }
  printf("%d\n", dp[n - 1].y);
}
