n, k = map(int, input().split())
a = [int(input()) for i in range(n)]
ans = 0
for i in range(n):
    x = [a[i]]
    cnt = 1
    for j in range(i+1, n):
        if abs(x[-1]-a[j]) <= k:
            x.append(a[j])
            cnt += 1
    ans = max(ans, cnt)
print(ans)