import sys

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

arr = []
dp = [1] * n
for _ in range(n):
    arr.append(int(sys.stdin.readline()))

for i in range(1, n):
    for j in range(0, i):
        if abs(arr[j] - arr[i]) <= k:
            dp[i] = max(dp[i], dp[j] + 1)

print(max(dp))
