import sys
from sys import stdin
def I():
    return stdin.readline().rstrip()
def MI():
    return map(int,stdin.readline().rstrip().split())
def LI():
    return list(map(int,stdin.readline().rstrip().split()))
#main part
N,K=MI()
a=[0]
for _ in range(N):
    a.append(int(I()))
dp=[0]*(N+1)
dp[1]=1
for i in range(2,N+1):
    ind=-1
    while i+ind>0:
        if abs(a[ind]-a[i])<=K:
            break
        ind-=1
    if i+ind==1:
        dp[i]=1
    else:
        dp[i]=dp[i+ind]+1
ans=0
for d in dp:
    if ans<d:
        ans=d
print(ans)