#include <bits/stdc++.h>
using namespace std;
int f(int arr[], int n, int k, int x) {
  int sum = 0;
  for (int j = 0; j < n; j++) {
    if (abs(arr[j] - x) <= k) sum++;
    x = arr[j];
  }
  return sum;
}
int main() {
  int n, k, count = 0;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    int x = f(arr, n, k, arr[i]);
    if (x > count) count = x;
  }
  cout << count;
}
