#include <bits/stdc++.h>
using namespace std;
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
  out << '(' << p.first << ", " << p.second << ')';
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
  long long l = v.size();
  for (long long i = 0; i < l - 1; i++) out << v[i] << ' ';
  if (l > 0) out << v[l - 1];
  return out;
}
template <typename T>
void trace(const char* name, T&& arg1) {
  cout << name << " : " << arg1 << "\n";
}
template <typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  trace(comma + 1, args...);
}
const long long N = 1e5 + 100;
long long n, m;
string s;
long long dpa[N], dpb[N];
long long dp[N];
long long cnt[N];
map<long long, long long> bound;
long long get(long long a, long long b) {
  if (a != 0) {
    return cnt[b] - cnt[a - 1];
  } else {
    return cnt[b];
  }
}
long long f(long long i, long long cnt, long long ans) {
  if (dp[i] != -1) {
    return dp[i];
  }
  if (dpa[i] >= m) {
    dp[i] = get(i, i + m - 1);
    if (cnt != ans) {
      dp[i] += f(i + m, cnt + 1, ans);
    }
  } else {
    dp[i] = 1000000000000000001;
  }
  if (i + 1 <= bound[cnt]) {
    dp[i] = min(dp[i], f(i + 1, cnt, ans));
  }
  return dp[i];
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  cin >> s;
  cin >> m;
  for (long long i = n - 1; i >= 0; i--) {
    if (s[i] == 'a') {
      dpa[i]++;
      dpa[i] += dpb[i + 1];
    } else if (s[i] == 'b') {
      dpb[i]++;
      dpb[i] += dpa[i + 1];
    } else {
      dpa[i]++;
      dpb[i]++;
      dpa[i] += dpb[i + 1];
      dpb[i] += dpa[i + 1];
    }
  }
  for (long long i = 0; i < n; i++) {
    if (i != 0) {
      cnt[i] += cnt[i - 1];
    }
    cnt[i] += (s[i] == '?');
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (dpa[i] >= m) {
      ans++;
      i = i + m - 1;
    }
  }
  long long curr = 1;
  for (long long i = 0; i < n; i++) {
    if (dpa[i] >= m) {
      bound[curr] = i + m - 1;
      curr++;
      i = i + m - 1;
    }
  }
  bound[ans] = n - 1;
  for (long long i = 0; i < N; i++) {
    dp[i] = -1;
  }
  long long final_ans = f(0, 1, ans);
  if (final_ans == 1000000000000000001) {
    cout << 0 << "\n";
  } else {
    cout << final_ans << "\n";
  }
}
