#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll N = 1e5+5;
ll n,k,dp[N][55],a[N];
ll solve(ll x,ll dis){
if(x>=n){
return 1;
}
if(dp[x][dis]!=-1)
return dp[x][dis];
ll mx=0,fre[55]={0};
for(ll i=x+1;i<=n;i++){
if(abs(a[x]-a[i])+dis<=k && (!fre[a[i]])){
mx=max(mx,solve(i,abs(a[x]-a[i])+dis)+1);
}else{
mx=max(mx,1LL);
}
fre[a[i]]=1;
}
return dp[x][dis]=mx;
}
int main()
{
// freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin >> n >> k;
for(int i=1;i<=n;i++)
cin >> a[i];
if(k==0){
cout << "1\n";
return 0;
}
memset(dp,-1,sizeof(dp));
ll ans=solve(1,0);
if(ans==0)
ans++;
cout << ans << endl;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgaW50IGxsOwoKY29uc3QgbGwgTiA9IDFlNSs1OwoKCmxsIG4sayxkcFtOXVs1NV0sYVtOXTsKCmxsIHNvbHZlKGxsIHgsbGwgZGlzKXsKCWlmKHg+PW4pewoJCXJldHVybiAxOwoJfQoKCWlmKGRwW3hdW2Rpc10hPS0xKQoJCXJldHVybiBkcFt4XVtkaXNdOwoKCWxsIG14PTAsZnJlWzU1XT17MH07Cglmb3IobGwgaT14KzE7aTw9bjtpKyspewoJCWlmKGFicyhhW3hdLWFbaV0pK2Rpczw9ayAmJiAoIWZyZVthW2ldXSkpewoJCQlteD1tYXgobXgsc29sdmUoaSxhYnMoYVt4XS1hW2ldKStkaXMpKzEpOwoJCQkKCQl9ZWxzZXsKCQkJbXg9bWF4KG14LDFMTCk7CgkJfQoJCWZyZVthW2ldXT0xOwoJfQoKCXJldHVybiBkcFt4XVtkaXNdPW14Owp9CgppbnQgbWFpbigpCnsKLy8gCWZyZW9wZW4oImluLnR4dCIsInIiLHN0ZGluKTtmcmVvcGVuKCJvdXQudHh0IiwidyIsc3Rkb3V0KTsKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKSxjaW4udGllKDApLGNvdXQudGllKDApOwogICAgY2luID4+IG4gPj4gazsKICAgIAogICAgZm9yKGludCBpPTE7aTw9bjtpKyspCiAgICAJY2luID4+IGFbaV07CiAgICBpZihrPT0wKXsKICAgICAgICBjb3V0IDw8ICIxXG4iOwogICAgICAgIHJldHVybiAwOwogICAgfQogICAgbWVtc2V0KGRwLC0xLHNpemVvZihkcCkpOwogICAgbGwgYW5zPXNvbHZlKDEsMCk7CiAgICBpZihhbnM9PTApCiAgICAgICAgYW5zKys7CiAgICBjb3V0IDw8IGFucyA8PCBlbmRsOwogICAgcmV0dXJuIDA7Cn0=