import bisect
n, k = map(int, input().split())
a = [int(input()) for _ in range(n)]
dp = [1 for _ in range(n)]
for i in range(n):
    for j in range(i-1, -1, -1):
        if abs(a[i] - a[j]) <= k:
            dp[i] = max(dp[i], dp[j]+1)
print(dp[-1])