import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
from collections import deque, defaultdict, Counter
import heapq

def main():
    N, K = MI()
    A = []
    dp = [0] * N
    dp[0] = 1
    for i in range(N):
        a = I()
        A.append(a)
    for i in range(1, N):
        x = -1
        for j in range(i - 1, -1, -1):
            if abs(A[j] - A[i]) <= K:
                x = j
                break
        if x == -1:
            dp[i] = dp[i - 1]
        else:
            dp[i] = max(dp[x] + 1, dp[i - 1])
    print(dp[N - 1])
if __name__ == "__main__":
    main()
