#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define BE(x) x.begin(), x.end()

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    int ans = 1, x = a[0], y;
    for (int i = 0; i < n; i++) {
        int tmp = 1;
        for (int j = j+1; j < n; j++) {
            y = a[j];
            if (abs(y-x) <= k) {
                x = y;
                tmp++;
            }
        }
        ans = max(tmp, ans);
        if (n-i <= ans) break;
    }
    cout << ans << endl;
}
