#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma comment(linker, "/STACK:2000000")
using namespace std;
using ll = long long;
using db = long double;
using ii = pair<int, int>;
const int N = 1e6 + 5, LG = 19, MOD = 998244353;
const int SQ = 320;
const long double EPS = 1e-7;
int n, k, l;
pair<ll, int> dp[N];
pair<ll, int> check(vector<int>& v, ll penalty) {
  deque<int> dq;
  for (int i = 0; i <= n; i++) {
    while (dq.size() && i - dq.front() > l) dq.pop_front();
    if (i) dp[i] = dp[i - 1];
    dp[i].first += v[i];
    if (i >= l) {
      dp[i] = min(dp[i], make_pair(penalty + dp[dq.front()].first,
                                   dp[dq.front()].second + 1));
    }
    while (dq.size() && dp[i] < dp[dq.back()]) dq.pop_back();
    dq.push_back(i);
  }
  return dp[n];
}
int solve(vector<int> v) {
  ll lo = 0, hi = 1e6;
  while (lo < hi) {
    ll md = lo + (hi - lo) / 2;
    if (check(v, md).second <= k)
      hi = md;
    else
      lo = md + 1;
  }
  auto x = check(v, lo);
  return x.first - k * lo;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k >> l;
  vector<int> v1({0}), v2({0});
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    v1.push_back((bool)islower(s[i]));
    v2.push_back((bool)isupper(s[i]));
  }
  cout << min(solve(v1), solve(v2)) << '\n';
  return 0;
}
