import bisect
n,k=map(int,input().split())
ans=[]
for i in range(n):
    a=int(input())
    ans.append(a)
l=[]
stack=[]
for i in range(n-1,-1,-1):
    while(stack and abs(ans[stack[-1]]-ans[i])>k):
        stack.pop()
    if stack:
        l.append(stack[-1])
    else:
        l.append(n)
    stack.append(i)
l.reverse()
dp=[]
for i in l:
    bi=bisect.bisect_left(dp,i)
    if len(dp)==bi:
        dp.append(i)
    dp[bi]=i
print(len(dp))

