#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000002;
int dp[maxn], cnt[maxn];
void solve_dp(vector<int> &a, int lambda, int l) {
  int i, f = 0, n = a.size() - 1, x, prev;
  dp[0] = 0;
  cnt[0] = 0;
  for (i = 1; i <= n; i++) {
    f += a[i];
    if (i > l) f -= a[i - l];
    dp[i] = dp[i - 1];
    cnt[i] = cnt[i - 1];
    if (i < l) {
      x = f - lambda;
      prev = 0;
    } else {
      x = dp[i - l] + f - lambda;
      prev = i - l;
    }
    if (x > dp[i]) {
      dp[i] = x;
      cnt[i] = cnt[prev] + 1;
    }
  }
}
int solve(vector<int> &a, int k, int l) {
  int lo = 0, hi = a.size(), mid;
  int n = a.size() - 1;
  while (lo != hi) {
    mid = lo + (hi - lo) / 2;
    solve_dp(a, mid, l);
    if (cnt[n] <= k) {
      hi = mid;
    } else {
      lo = mid + 1;
    }
  }
  solve_dp(a, lo, l);
  return dp[n] + lo * k;
}
int main() {
  int n, k, l, i, nL = 0, nU;
  cin >> n >> k >> l;
  string s;
  cin >> s;
  vector<int> a(n + 1);
  a[0] = 0;
  for (i = 1; i <= n; i++) {
    a[i] = islower(s[i - 1]) ? 1 : 0;
    if (a[i]) nL++;
  }
  nU = n - nL;
  int ans = nL - solve(a, k, l);
  for (i = 1; i <= n; i++) {
    a[i] = 1 - a[i];
  }
  ans = min(ans, nU - solve(a, k, l));
  cout << ans << endl;
  return 0;
}
