#include <bits/stdc++.h>
using namespace std;
long long a[300005], c, d, e = 0, f, i, j, k, l;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> c >> d;
  for (i = 0; i < c; i++) {
    cin >> a[i];
  }
  f = 0;
  for (i = f; i < c - 1; i++) {
    for (j = i + 1; j < c; j++) {
      if (a[j] - a[i] <= d) {
        e++;
        f = j;
        break;
      } else if (a[j] - a[i] > d) {
        f = j;
        break;
      }
    }
  }
  cout << e << endl;
  return 0;
}
