package main import ( "fmt" "os" "bufio" "sort" ) var in=bufio.NewReader(os.Stdin) func main() { var n,k int fmt.Scan(&n,&k) arr:=make([]int,n) for i:=0;i<n;i++{ fmt.Fscan(in,&arr[i]) } sort.Ints(arr) ans:=0 for l,r:=0,0;r<len(arr);r++{ for arr[r]-arr[l]>k{ l++ } if r-l+1>ans{ ans=r-l+1 } } fmt.Print(ans) }