#include <bits/stdc++.h>
using namespace std;
const int S = 1000 * 1000 + 5;
const int A = 26;
const int M = 7 * 17 * 1024 * 1024 * 8 + 1;
const long long int C = (long long int)S * S * S + 5;
const int NONE = 0;
string s;
int n, rk, len;
long long int lambda;
long long int v[S];
long long int dp[S];
long long int usedseg[S];
long long int realsum[S];
long long int prefsum[S];
void radix_engine(vector<int> &order, vector<int> &keys) {
  vector<int> radix_class;
  vector<int> new_order(order.size());
  int max_key = 0;
  for (auto key : keys) max_key = max(max_key, key);
  radix_class.resize(max_key + 1, 0);
  for (auto key : keys) radix_class[key]++;
  int accum = 0;
  for (unsigned int i = 0; i < radix_class.size(); i++) {
    int start = accum;
    accum += radix_class[i];
    radix_class[i] = start;
  }
  for (auto e : order) {
    int k = keys[e];
    new_order[radix_class[k]] = e;
    radix_class[k]++;
  }
  order.swap(new_order);
}
void test() {
  cin >> n >> rk >> len >> s;
  long long int ans = n;
  for (int i = 0; i < n; i++) v[i] = ('a' <= s[i] && s[i] <= 'z');
  for (int twice = 0; twice < 2; twice++) {
    for (int i = 0; i < n; i++) v[i] ^= 1;
    for (int i = 0; i < n; i++) prefsum[i + 1] = prefsum[i] + v[i];
    long long int lambda_l = -1;
    long long int lambda_r = C;
    while (lambda_r - lambda_l > 1) {
      long long int lambda_mid = (lambda_r + lambda_l) / 2;
      for (int i = 0; i < n; i++) {
        dp[i + 1] = dp[i];
        usedseg[i + 1] = usedseg[i];
        realsum[i + 1] = realsum[i];
        int iz = max(0, i + 1 - len);
        long long int izsum = prefsum[i + 1] - prefsum[iz];
        long long int dpz = dp[iz] + izsum * n * n - lambda_mid - i;
        if (dp[i + 1] < dpz) {
          dp[i + 1] = dpz;
          usedseg[i + 1] = usedseg[iz] + 1;
          realsum[i + 1] = realsum[iz] + izsum;
        }
      }
      if (usedseg[n] > rk) {
        lambda_l = lambda_mid;
      } else {
        lambda_r = lambda_mid;
        ans = min(prefsum[n] - realsum[n], ans);
      }
    }
  }
  cout << ans << endl;
}
void solve() { test(); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed;
  cout.precision(20);
  solve();
}
