#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
const int INF = 0x3f3f3f3f;
int n, m;
int p[MAXN];
int tag[MAXN], pre[MAXN];
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(10) << fixed;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> p[i];
  sort(p, p + n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int u = lower_bound(p, p + i, p[i] - m) - p;
    int v = lower_bound(p, p + i, p[i]) - p;
    cnt += (v - u);
    tag[u]++;
    tag[v]--;
  }
  for (int i = 0; i < n; i++) {
    if (!i)
      pre[i] = tag[i];
    else
      pre[i] = pre[i - 1] + tag[i];
    cnt -= max(pre[i] - 1, 0);
  }
  cout << n - cnt << endl;
  return 0;
}
