#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
string s;
int n, k, len, a[N], prefix[N], cnt[N], dp[N];
bool judge(int x) {
  for (int i = 1; i <= n; ++i) {
    dp[i] = dp[i - 1] + a[i];
    cnt[i] = cnt[i - 1];
    if (i < len) {
      if (dp[i] > x) dp[i] = x, cnt[i] = 1;
    } else {
      if (dp[i] > dp[i - len] + x) {
        dp[i] = dp[i - len] + x;
        cnt[i] = cnt[i - len] + 1;
      }
    }
  }
  return cnt[n] <= k;
}
int solve(void) {
  for (int i = 1; i <= n; ++i) {
    prefix[i] = prefix[i - 1] + a[i];
  }
  int l = 0, r = n, ans;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (judge(mid)) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  judge(ans);
  return dp[n] - ans * k;
}
int main(void) {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> k >> len;
  cin >> s;
  for (int i = 0; i < n; ++i) {
    if ('a' <= s[i] && s[i] <= 'z')
      a[i + 1] = 0;
    else
      a[i + 1] = 1;
  }
  int ans = solve();
  for (int i = 0; i < n; ++i) {
    if ('a' <= s[i] && s[i] <= 'z')
      a[i + 1] = 1;
    else
      a[i + 1] = 0;
  }
  ans = min(ans, solve());
  cout << ans << endl;
  return 0;
}
