#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n,k = ip()
x = [inp() for i in range(n)]
dp = [1]*n
for i in range(n):
    for j in range(i):
        if abs(x[i]-x[j]) <= k:
            dp[i] = max(dp[i],dp[j]+1)
print(max(dp))