/*
ID: hursh171
LANG: C++
TASK: test
*/
// Sat Sep 19 20:03:13 IST 2020   
#include <bits/stdc++.h>        
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(ii,a,b)       for(int64 ii = (int64)a ; ii < (int64)b  ; ii++ )
#define scan(any)          for(auto &i:any) cin>>i;
#define debug(x)           cerr << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long   
#define all(x)             (x).begin(),(x).end() 
#define ff                 first
#define ss                 second
#define pppp               pair <int,int> 
#define flushOff           fflush(stdout) 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;    
// policy based   
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
 
const int MOD1 = 1e9+7;
const int MOD2 = 1e9+9;
const int weird_mod = 998244353;
const double pi = 3.141592653589793238;
const int INF = 2e9+7;
const int64 big = 1e18;

const int N = 2e5+7;
struct compare{
    bool operator()(pair <int,int> A, pair <int,int> B){
        if(A.first == B.first)
            return A.second > B.second;
        return A.first > B.first;
    }
}; 
void print(vector <int>v){
    for(int t : v) 
        cout << t << ' ';
    cout << '\n';
    return;
}  
vector <int> a;
int k;
int solve(int index){
    if(index == (int)a.size())
        return 0;
    int way1 = solve(index+1) ;
    int ways = 0;
    
    if(index+1 < (int)a.size() && abs(a[index+1] - a[index]) <= k){
        ways = max(ways,1+way1);
    }  
    return ways;
}
int tests(){
    int n;
    cin >> n  >> k;
    a.resize(n);
    for(auto &x :a)
        cin >> x; 
    int v[n][2] = {0};
    int dp[n][2] = {0};
    v[0][0] = 0;
    v[0][1] = a[0];
    dp[0][0] = 0;
    dp[0][1] = 1;
    forn(i,1,n){ 
        if(dp[i-1][0] >= dp[i-1][1]){
            dp[i][0] = dp[i-1][0];
            v[i][0] = v[i-1][0];
        }
        if(dp[i-1][1] > dp[i-1][0]){
            dp[i][0] = dp[i-1][1];
            v[i][0] = v[i-1][1];
        }
        if(abs(a[i] - v[i-1][0]) <= k){
            dp[i][1] = dp[i-1][0] +1 ;
            v[i][1] = a[i];
        }
        if(abs(a[i] - v[i-1][1]) <= k){
            dp[i][1] = dp[i-1][1] + 1;
            v[i][1] = a[i];
        }
    } 
        
    cout << max(dp[n-1][0],dp[n-1][1]) << '\n';
    return 0;
}    
int main(){
    I__O ;     
    int cases = 1;
    // cin >> cases; 
    while(cases--)
        tests(); 
    return 0 ; 
}
 
