import sys
from collections import deque, defaultdict, Counter
from itertools import accumulate, product, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush
from math import ceil, floor, sqrt, gcd, inf
from copy import deepcopy
import numpy as np
import scipy as sp

INF = inf
MOD = 1000000007

n, k = [int(i) for i in input().split()]
A = [int(input()) for j in range(n)]    # nは行数

tmp = [[A[0]]]
res = 1

for i in range(1, n):
    tmp_2 = []
    flg = False
    for j in tmp:
        if abs(j[-1] - A[i]) <= k:
            if len(j) >= len(tmp_2):
                tmp_2 = j
                flg = True
    if flg:
        tmp_2.append(A[i])
    else:
        tmp.append([A[i]])

for i in tmp:
    res = max(res, len(i))

print(res)
