#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 100;
long long n, k, l;
string s;
long long p[maxn], cnt[maxn];
pair<long long, long long> dp[maxn];
bool check(long long x) {
  dp[0] = make_pair(0, 0);
  for (long long i = 1; i <= n; i++) {
    dp[i] = dp[i - 1];
    dp[i].first += p[i];
    if (i - l > 0)
      dp[i] = min(dp[i], make_pair(dp[i - l].first + x, dp[i - l].second + 1));
    else
      dp[i] = min(dp[i], make_pair(x, 1ll));
  }
  return dp[n].second <= k;
}
signed main() {
  cin >> n >> k >> l;
  cin >> s;
  for (long long i = 1; i <= s.size(); i++)
    p[i] = (s[i - 1] >= 'A' && s[i - 1] <= 'Z');
  n = s.size();
  long long a = 0, b = s.size(), ans, x;
  while (a <= b) {
    long long mid = (a + b) >> 1;
    if (!check(mid))
      a = mid + 1;
    else
      b = mid - 1, x = mid;
  }
  check(x);
  ans = dp[n].first - x * k;
  for (long long i = 1; i <= s.size(); i++) p[i] = p[i] ^ 1;
  a = 0, b = s.size(), x;
  while (a <= b) {
    long long mid = (a + b) >> 1;
    if (!check(mid))
      a = mid + 1;
    else
      b = mid - 1, x = mid;
  }
  check(x);
  ans = min(ans, dp[n].first - x * k);
  cout << ans << endl;
}
