#import<atcoder/all>
using namespace std;int o(int a,int b){return a<b?b:a;}int e(){return 0;}int K,A;atcoder::segtree<int,o,e>P(3<<17);main(){for(cin>>K>>K;cin>>A;)P.set(A,P.prod(o(0,A-K),min(3<<17,A+K)+1)+1);cout<<P.all_prod();}