#include <bits/stdc++.h>
using namespace std;
int main() {
  long int a, b;
  cin >> a >> b;
  int arr[a], visited[a];
  vector<int> v;
  for (int i = 0; i < a; i++) {
    cin >> arr[i];
    visited[i] = 0;
  }
  int ans = 0;
  for (int i = 0; i < a; i++) {
    if (visited[i] == 0) {
      int top = arr[i];
      visited[i] = 1;
      int count = 1;
      for (int j = i + 1; j < a; j++) {
        if (abs(top - arr[j]) <= b) {
          top = arr[j];
          visited[j] = 1;
          count += 1;
        }
      }
      if (count > ans) ans = count;
    }
  }
  cout << ans;
}
