#include <bits/stdc++.h>
using namespace std;
int fun(vector<int> arr, int last, int n, int i, int k) {
  if (i == n) {
    return 0;
  }
  if (last == -1 || abs(arr[i] - last) <= k) {
    return max(fun(arr, last, n, i + 1, k), 1 + fun(arr, arr[i], n, i + 1, k));
  } else {
    return fun(arr, last, n, i + 1, k);
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    arr.push_back(num);
  }
  cout << fun(arr, -1, n, 0, k);
}
