#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chkmax(T &x, T y) {
  return x < y ? x = y, true : false;
}
template <class T>
bool chkmin(T &x, T y) {
  return x > y ? x = y, true : false;
}
template <class A, class B>
A cvt(B x) {
  stringstream s;
  s << x;
  A r;
  s >> r;
  return r;
}
void read() {}
void print() {}
template <class T, class... Args>
void read(T &a, Args &...args) {
  cin >> a;
  read(args...);
}
template <class T, class... Args>
void print(T a, Args... args) {
  cout << a << ' ';
  print(args...);
}
template <class... Args>
void println(Args... args) {
  print(args...);
  cout << '\n';
}
void cerr_(istream_iterator<string> it) { (void)it; }
template <class T, class... Args>
void cerr_(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  cerr_(++it, args...);
}
template <class T, class S>
ostream &operator<<(ostream &os, const pair<T, S> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '{';
  string sep;
  for (const auto &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &s) {
  os << '{';
  string sep;
  for (const auto &x : s) os << sep << x, sep = ", ";
  return os << '}';
}
template <class T, class S>
ostream &operator<<(ostream &os, const map<T, S> &m) {
  os << '{';
  string sep;
  for (const auto &x : m) os << sep << x, sep = ", ";
  return os << '}';
}
template <class T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr) {
  os << '{';
  string sep;
  for (const auto &x : arr) os << sep << x, sep = ", ";
  return os << '}';
}
const int INF = 0x3F3F3F3F;
const int MAXN = (int)1e5 + 1;
const int MOD = (int)1e9 + 7;
void run_test() {
  int n, k;
  read(n, k);
  vector<int> a(n);
  for (int i = 0; i < n; i++) read(a[i]);
  int ans = 0;
  vector<bool> vis(n);
  for (int j = 0; j < n; j++)
    if (!vis[j]) {
      int cur = 0;
      int last = a[j];
      for (int i = (j) - ((j) > (n)); i != (n) - ((j) > (n));
           i += 1 - 2 * ((j) > (n)))
        if (abs(a[i] - last) <= k) {
          vis[i] = true;
          last = a[i];
          cur++;
        }
      ans = max(ans, cur);
    }
  println(ans);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  run_test();
  return 0;
}
