import sys
import bisect
input=sys.stdin.readline

n, k = map(int,input().split())

A = []
for i in range(n):
    a = int(input())
    A.append(a)

ans = [0,A[0]]
for i in range(1,n):
    if abs(A[i]-ans[-1]) <= k:
        ans.append(A[i])
    else:
        ind = bisect.bisect_right(ans, A[i])
        if ind >= 0 and ind < len(ans):
            ans.insert(ind, A[i])
        else:
            if -ind-1 > len(ans)-1:
                if A[i] - ans[-1] <= k:
                    ans.append(A[i])
            else:
                if -ind-1 == 0:
                    ans.insert(-ind-1, A[i])
                elif A[i] - ans[-2] <= k:
                    ans.insert(-ind-1, A[i])
print(len(ans)-2)
