#include <bits/stdc++.h>
using namespace std;
long long ar[300005];
int main() {
  long long n, k, len = 0, len1 = 0;
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> ar[i];
  }
  long long age = ar[0], pore = ar[1];
  for (long long i = 1, j = 2; i <= n && j < n;) {
    if (abs(ar[i] - ar[j]) <= k) {
      len++;
      i++;
      j++;
    } else
      j++;
  }
  for (long long i = 1, j = 2; i <= n && j < n; i++, j++) {
    if (abs(ar[i] - ar[j]) <= k) {
      len1++;
    }
  }
  cout << max(len, len1) << endl;
  return 0;
}
