#include <bits/stdc++.h>
using namespace std;
int n, m, k, c[200002], a[200002], len[200002], aw[200002];
int lowbit(int x) { return x & (-x); }
void add(int x, int s) {
  for (int i = x; i <= n + 1; i += lowbit(i)) c[i] += s;
}
int find(int x, int y) {
  int s = 0;
  for (int i = y; i > 0; i -= lowbit(i)) s += c[i];
  for (int i = x - 1; i > 0; i -= lowbit(i)) s -= c[i];
  return s;
}
int main() {
  scanf("%d%d%d\n", &n, &m, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  sort(a + 1, a + n + 1);
  int l, r, mid, x, t;
  int ans = 0;
  for (int i = 1; i <= n; ++i) add(i, 1);
  for (int i = 1; i <= n; ++i) {
    l = i + 1, r = n, mid = (l + r) / 2;
    x = i;
    while (l <= r) {
      if (a[mid] - a[i] < m)
        x = mid, l = mid + 1;
      else
        r = mid - 1;
      mid = (l + r) / 2;
    }
    len[i] = min(x, n);
    t = find(i, len[i]) - k + 1;
    if (t >= 1) {
      ans += t;
      int j = len[i];
      while (t && j >= 1) {
        if (find(j, j) == 0)
          j = aw[j];
        else {
          add(j, -1);
          j--;
          t--;
        }
      }
      aw[len[i]] = j;
    }
  }
  printf("%d", ans);
  return 0;
}
