#include <bits/stdc++.h>
using namespace std;
const int nax = 1e6 + 100;
int n, k, l;
string s;
bool a[nax];
long long ans = 1e18;
pair<long long, int> check(long long d) {
  vector<pair<long long, int>> dp(n + 2, {(long long)1e18, 0});
  for (int i = 0; i < n; i++) {
    {
      pair<long long, int> nxt = (i ? dp[i - 1] : make_pair(0ll, 0));
      nxt.first += a[i];
      dp[i] = min(dp[i], nxt);
    }
    {
      pair<long long, int> nxt = (i - l >= 0 ? dp[i - l] : make_pair(0ll, 0));
      nxt.first += d;
      nxt.second++;
      dp[i] = min(dp[i], nxt);
    }
  }
  return dp[n - 1];
}
void solve() {
  int md, lo = 0, hi = 1e9, lamda = -1;
  while (lo <= hi) {
    md = (lo + hi) / 2;
    int need = check(md).second;
    if (need <= k) {
      hi = md - 1;
      lamda = md;
    } else {
      lo = md + 1;
    }
  }
  pair<long long, int> tmp = check(lamda);
  ans = min(ans, tmp.first - k * lamda);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  cin >> n >> k >> l >> s;
  for (int i = 0; i < n; i++) a[i] = islower(s[i]);
  solve();
  for (int i = 0; i < n; i++) a[i] = isupper(s[i]);
  solve();
  cout << ans << endl;
}
