#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int n, d;
  cin >> n >> d;
  unsigned long long int i, a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  if (n == 1) {
    i = 0;
    cout << i;
    return 0;
  }
  unsigned long long int mi = INT_MAX;
  for (i = 0; i < n; i++) {
    mi = min(mi, a[i]);
  }
  unsigned long long int ma = mi + d, c = 0;
  for (i = 0; i < n; i++) {
    if (a[i] > ma) c++;
  }
  cout << c;
  return 0;
}
