n, k = map(int,input().rstrip().split())
a = [0]*n
for i in range(n):
    a[i] = int(input())
b = [a[0]]
now = a[0]
second = -1
for i in range(1,n):
    if abs(now-a[i])<=k:
        b.append(a[i])
        now = a[i]
        if second == -1:
            second = i
l = [len(b)]
for i in range(1,second):
    b = [a[i]]
    now = a[i]
    for j in range(i+1,n):
        if abs(now-a[j])<=k:
            b.append(a[j])
            now = a[j]
    l.append(len(b))
print(max(l))