program answer
  implicit none
  integer(8) :: i, j, N, K, ans, f, tmp, b, c
  integer(8), allocatable :: A(:), han(:)
  read(*,*) N, K
  allocate(A(N),han(N))
  do i = 1, N
     read(*,*) A(i)
  end do
  ans=1
  do i = 1, N-1
     if(abs(A(i)-A(i+1))<=K) then
        f=i
        exit
     end if
  end do

  ans=1
  han=0
  do i = 1, N-1
     if(han(i)==1) then
        cycle
     end if
     tmp=1
     b=A(i)
     j=1
     do
        if(i+j>=N+1) then
           exit
        end if
        if(han(i+j)==1) then
           j=j+1
        else
           if(abs(A(i+j)-b)<=K) then
              han(i+j)=1
              han(i)=1
              tmp=tmp+1
              b=A(i+j)
              j=j+1
           else
              j=j+1
           end if
        end if
     end do
     ans=max(ans,tmp)
  end do
  
  write(*,*) ans
  stop
 end program answer