#include <bits/stdc++.h>
using namespace std;
int a[1000001];
int l, r;
int jum, jaw;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  k--;
  for (int i = 1; i <= n; i++) {
    int dum;
    cin >> dum;
    a[dum]++;
  }
  l = 1;
  r = m;
  for (int i = 1; i <= m; i++) {
    if (a[i] + jum > k) {
      jaw += jum + a[i] - k;
      a[i] = k - jum;
      jum = k;
    } else {
      jum += a[i];
    }
  }
  while (r < 1000000) {
    r++;
    jum -= a[l];
    l++;
    if (a[r] + jum > k) {
      jaw += jum + a[r] - k;
      a[r] = k - jum;
      jum = k;
    } else {
      jum += a[r];
    }
  }
  cout << jaw << endl;
}
