package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	K := nextInt()

	a := make([]int, n)
	aflag := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	max := 0
	for mk, v := range a {
		if aflag[mk] == 1 {
			continue
		}
		aflag[mk] = 1
		tmp := 1
		beforvalue := v
		for sk := mk + 1; sk < len(a); sk++ {
			if abs(a[sk]-beforvalue) <= K {
				//fmt.Println([]int{beforvalue, a[sk]})
				aflag[sk] = 1
				tmp++
				beforvalue = a[sk]
			}
		}
		if max < tmp {
			max = tmp
		}
	}
	fmt.Println(max)
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func isort(s []int) []int {
	sort.Slice(s, func(i, j int) bool { return s[i] < s[j] })
	return s
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
