def dfs(start):
  global myList
  if start==n:
    return
  if len(myList) == 0:
    myList.append(a[start])
    dfs(start+1)
  else:
    if abs(myList[-1]-a[start])<=k:
      myList.append(a[start])
    dfs(start+1)  

n,k = map(int,input().split())
a = []
for i in range(n):
  a.append(int(input()))
#print(a)
ans = 0
for i in range(n):
  myList = []
  dfs(i)
  ans = max(ans,len(myList))
print(ans)