#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e6;
void tc() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> arr(n + 1, -100);
  for (int i = 1; i < n + 1; i++) {
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  int p1 = 1, p2 = 0;
  if (m < k) {
    cout << 0 << "\n";
    return;
  }
  int i = 1;
  int rem = 0, cur = 0;
  vector<int> f(mxn + 3, 0);
  stack<int> s;
  while (i <= n and p2 <= mxn) {
    ++p2;
    if (arr[i] <= p2) {
      cur++;
      s.push(arr[i]);
      f[arr[i]] = 1;
      ++i;
    }
    if (p2 - p1 + 1 > m) {
      if (f[p1] == 1) {
        f[p1]--;
        cur--;
      }
      ++p1;
    }
    int out = cur - (k - 1);
    if (out > 0) {
      rem += out;
      while (out--) {
        int top = s.top();
        f[top] = 0;
        s.pop();
        --cur;
      }
    }
  }
  cout << rem << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) tc();
}
