#include <bits/stdc++.h>
const int N = 3e6;
const int M = 1e6;
#define ll long long
const ll MOD = 1e9 + 1;
const ll INF = 1e15;
const ll base = 32;
#define fi first
#define se second
using namespace std;

ll n, t;
ll a[N+3];
deque<ll> ma, mi;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    // freopen("main.inp","r",stdin);
    // freopen("main.out","w",stdout);
    cin>>n>>t;
    for(int i=1;i<=n;i++)cin>>a[i];
    int l = 1, r = n, ans = 0;
    while(l <= r){
        int mid = l + r >> 1;
        ll res = 0, cnt = 0;
        while(!ma.empty())ma.pop_back();
        while(!mi.empty())mi.pop_back();
        // cout<<mid<<"\n";
        for(int i=1;i<mid;i++){
            while(!ma.empty() and a[ma.back()] <= a[i])ma.pop_back();
            ma.push_back(i);
        }
        for(int i=1;i<mid;i++){
            while(!mi.empty() and a[mi.back()] >= a[i])mi.pop_back();
            mi.push_back(i);
        }
        for(int i=mid;i<=n;i++){
            while(!ma.empty() and a[ma.back()] <= a[i])ma.pop_back();
            ma.push_back(i);
            if(ma.front() <= i - mid)ma.pop_front();

            while(!mi.empty() and a[mi.back()] >= a[i])mi.pop_back();
            mi.push_back(i);
            if(mi.front() <= i - mid)mi.pop_front();
            // cout<<a[ma.front()]<<" "<<a[mi.front()]<<"\n";
            res = abs(a[ma.front()] - a[mi.front()]);
            if(res <= t){
                cnt++;
                break;
            }
        }
        if(cnt > 0){
            ans = mid;
            l = mid + 1;
        }
        else r = mid - 1;
    }
    cout<<ans<<"\n";
    return 0;
}
