#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define vp vector <pair<int,int>>
#define f(x,y,z) for(x=y;x<z;x++)
#define pb push_back
#define mp make_pair
#define ld long double
#define fb(x,y,z) for(x=y;x>z;x--)
#define pqf priority_queue <int,vector <int>> 
#define pqb priority_queue <int,vector <int>,greater<int>> 
#define ps(x,y) fixed << setprecision(y) << x
#define PI 3.1415926535
#define mod 1000000007 
#define mods 998244353 
#define setbits(x) __builtin_popcountll(x)
#define all(x) (x).begin(), (x).end()
#define fill(a,b) memset(a,b,sizeof(a))


// AUTHOR ALOK KUMAR
int lcm(int a,int b)
{
    return (a*b)/(__gcd(a,b));
}
int power(int a,int b)
{
    int c=1;
    while(b)
    {
        if(b&1)
        c*=a;
        a*=a;
        b>>=1;
    }
    return c;
}
int ans;
int flag[300000+1];
int calc(int a[],int n, int i,int curvalue,int k)
{
    if(i==n)
    {
        return 0;
    }
    
    int ans=0;
    if(abs(curvalue-a[i])<=k)
    {
        return max(flag[i],calc(a,n,i+1,curvalue,k));
    }
    else return calc(a,n,i+1,curvalue,k);
    
    
}
void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    int i,j,k1,k2;
    ans=1;
    fill(flag,-1);
    f(i,0,n)
    cin>>a[i];
    
    int ans1=1;
    for(i=n-1;i>=0;i--)
    flag[i]=calc(a,n,i,a[i],k)+1;
    ans1=1;
    f(i,0,n)
    ans1=max(ans1,flag[i]);
    cout<<ans1<<"\n";
    
    
    
    
    
    
}



int32_t main()
{
    IOS
    int t=1;
   // cin>>t;
    while(t--)
    solve();
    return 0;
}

































