#include <bits/stdc++.h>
using namespace std;
vector<int> arr[100001];
int vis[100001];
int cc;
void dfs(int i) {
  vis[i] = 1;
  for (int child : arr[i]) {
    if (vis[child] == 0) dfs(child);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, s, l;
  cin >> n >> s;
  long long int a[n];
  long long int cc, max = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int k = 0; k < n - 1; k++) {
    cc = 1;
    l = a[k];
    for (int i = k + 1; i < n; i++) {
      if (abs(l - a[i]) <= s) {
        l = a[i];
        cc++;
      }
    }
    max = std::max(max, cc);
  }
  cout << max << endl;
  return 0;
}
