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