import bisect
n,k=map(int,input().split())
ans=[]
for i in range(n):
    a=int(input())
    ans.append(a)
stack=[]
ma=[1]*(n+1)
for i in range(n-1,-1,-1):
    ma[i]=ma[i+1]
    while(stack and abs(ans[stack[-1]]-ans[i])<=k):
        c=stack.pop()
        if ma[c]+1>ma[i]:
            ma[i]=ma[c]+1
    stack.append(i)
print(ma[0])

