#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
const long long mod = (long long)1e9 + 7;
const double eps = (double)1e-9;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
const int N = 1000500;
pair<long long, int> dp[N];
bool val[N];
int n, k, ln;
inline pair<long long, int> get(int C, bool tp) {
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    dp[i].first += (val[i] == tp);
    if (i >= ln)
      dp[i] = min(dp[i], {dp[i - ln].first + C, dp[i - ln].second + 1});
  }
  return dp[n];
}
int main() {
  scanf("%d %d %d\n", &n, &k, &ln);
  if (k * 1ll * ln >= n) {
    printf("0");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    char c = getchar();
    val[i] = ('A' <= c && c <= 'Z');
  }
  long long ans = inf;
  for (int i = 0; i < 2; i++) {
    int l = 0, r = n, res;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (get(mid, i).second <= k) {
        res = mid;
        r = mid - 1;
      } else
        l = mid + 1;
    }
    pair<long long, int> cur = get(res, i);
    ans = min(ans, cur.first - res * 1ll * k);
  }
  printf("%lld", ans);
  return 0;
}
