package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var (
	sc = bufio.NewReader(os.Stdin)
)

func main() {
	N, K := scanInt(), scanInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = scanInt()
	}

	max := 0
	for i := 0; i < N; i++ {
		if max > N-i {
			break
		}

		length := 1
		c := A[i]
		for j := i + 1; j < N; j++ {
			if max > length+N-j {
				break
			}
			if abs(c-A[j]) <= K {
				length++
				if length > max {
					max = length
				}
			}
			c = A[j]
		}
	}
	fmt.Println(max)
}

func abs(a int) int         { return int(math.Abs(float64(a))) }
func scan(a ...interface{}) { _, err := fmt.Fscan(sc, a...); pnc(err) }
func scanStr() (s string)   { scan(&s); return }
func scanInt() int          { i, err := strconv.Atoi(scanStr()); pnc(err); return i }
func scanFloat() float64    { f, err := strconv.ParseFloat(scanStr(), 64); pnc(err); return f }
func pnc(err error) {
	if err != nil {
		panic(err)
	}
}
