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