#include <bits/stdc++.h>
using namespace std;
inline char nc() {
  static char buf[1000000], *p1, *p2;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <typename T>
inline int scan(T &x) {
  char c, sign = 1;
  while (!isdigit(c = nc()) && c != EOF)
    if (c == '-') sign *= -1;
  if (c == EOF) return EOF;
  for (x = 0; isdigit(c); c = nc()) x = (x << 1) + (x << 3) + (c & 15);
  return x *= sign, 1;
}
template <typename T, typename... Args>
inline int scan(T &x, Args &...args) {
  return scan(x), scan(args...);
}
const int N = 1 << 20;
int n, k, l;
int a[N];
pair<long long, int> dp[N];
pair<long long, int> chk(int x) {
  for (int i = 0; i < n; ++i) {
    dp[i] = {1LL << 61, 0};
    pair<long long, int> tp;
    tp = i >= l ? dp[i - l] : pair<long long, int>({0, 0});
    tp.first += x;
    tp.second++;
    dp[i] = min(dp[i], tp);
    tp = i ? dp[i - 1] : pair<long long, int>({0, 0});
    tp.first += a[i];
    dp[i] = min(dp[i], tp);
  }
  return dp[n - 1];
}
int go() {
  for (int i = 0; i < n; ++i) a[i] ^= 1;
  int L = 0, R = n, mid, ans, ret;
  while (R >= L) {
    mid = (L + R) >> 1;
    if (chk(mid).second <= k)
      ans = mid, R = mid - 1;
    else
      L = mid + 1;
  }
  return chk(ans).first - 1LL * ans * k;
}
int main() {
  cin >> n >> k >> l;
  string s;
  cin >> s;
  for (int i = 0; i < n; ++i) a[i] = islower(s[i]) != 0;
  cout << min(go(), go()) << endl;
}
