#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int a[n];
  vector<int> vis(n, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  int mx = 0;
  for (int i = 0; i < n; i++) {
    int count = 0;
    int temp = a[i];
    if (vis[i] == 0) {
      for (int j = i + 1; j < n; j++) {
        if (abs(temp - a[j]) <= k) {
          vis[j] = 1;
          temp = a[j];
          count++;
        }
      }
      cout << i << " " << count << "\n";
      if (count > 0) mx = max(count + 1, mx);
      vis[i] = 1;
    }
  }
  cout << mx << "\n";
  return 0;
}
