#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int n,k;
cin>>n>>k;
vector<int> arr(n);
for(int i=0;i<n;i++){
cin>>arr[i];
}
int diff =0;
int i=0,j=0;
int ans = 0;
while(j<n){
diff = abs(arr[j]-arr[i]);
if(diff<=k){
ans=max(ans,j-i+1);
}else if(diff>k){
while(diff>k&&i<=j){
diff = abs(arr[j]-arr[i]);
i++;
}
}
j++;
}
cout<<ans;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCWludCBuLGs7CgljaW4+Pm4+Pms7Cgl2ZWN0b3I8aW50PiBhcnIobik7Cglmb3IoaW50IGk9MDtpPG47aSsrKXsKCQljaW4+PmFycltpXTsKCX0KCWludCBkaWZmID0wOwoJaW50IGk9MCxqPTA7CglpbnQgYW5zID0gMDsKCXdoaWxlKGo8bil7CgkJZGlmZiA9IGFicyhhcnJbal0tYXJyW2ldKTsKCQlpZihkaWZmPD1rKXsKCQkJYW5zPW1heChhbnMsai1pKzEpOwoJCX1lbHNlIGlmKGRpZmY+ayl7CgkJCXdoaWxlKGRpZmY+ayYmaTw9ail7CgkJCQlkaWZmID0gYWJzKGFycltqXS1hcnJbaV0pOwoJCQkJaSsrOwoJCQl9CgkJfQoJCQoJCWorKzsKCX0KY291dDw8YW5zOwoKCXJldHVybiAwOwp9