#include <bits/stdc++.h>
using namespace std;
long long int n, m, k, l, r, county1, ans, county2, pos, index1, index2;
int a[200005], b[400005];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  r = 0;
  county2 = 0;
  county1 = 0;
  pos = -1;
  index1 = 0;
  if (n == 1) {
    if (k == 1)
      cout << 1;
    else
      cout << 0;
  } else {
    while (l <= r && r < n) {
      if (a[r] - a[l] + 1 <= m) {
        r++;
        county2++;
      } else {
        if (county2 >= k) {
          if (county1 < county2 - k + 1) {
            ans += (county2 - k + 1 - county1);
            b[index1++] = r - county2 + k + county1 - 1;
            b[index1++] = r - 1;
            county1 = county2 - k + 1;
            if (index1 > index2 && pos == -1) {
              pos = b[index2];
            }
          }
        }
        if (l == pos && county1 > 0) {
          county1--;
          if (pos == b[index2 + 1]) {
            if (index1 >= index2 + 2) {
              pos = b[index2 + 2];
              index2 += 2;
            } else
              pos = -1;
          } else
            pos++;
          if (county1 == 0) pos = -1;
        }
        county2--;
        l++;
      }
    }
    if (r == n) {
      if ((county2 - k + 1 - county1) > 0) ans += (county2 - k + 1 - county1);
    }
    cout << ans;
  }
}
