package main

import(
  "fmt" 
  "math"
)

type Node struct{
  longest int
  val int
}

/* コンストラクタ */
func newNode(n int) *Node {
    node := new(Node)
    node.longest = -1
    return node
}

func main(){
  var n, k, tmp int
  var a []Node
  
  fmt.Scanf("%d %d", &n, &k)
  for i:=0; i < n ; i++{
    fmt.Scanf("%d", &tmp)
    node := newNode(n)
    node.val = tmp
    a = append(a, *node)
  }
  
  
  a[0].longest = 1
  for i:= 1; i< n; i++{
    longest := -1
    for j:= 0 ; j < i; j++{
      if(math.Abs(float64(a[j].val) - float64(a[i].val)) <= float64(k) && a[j].longest > longest){
        longest = a[j].longest
        //longest_j := j
      }
    }
    a[i].longest = longest+1
  }
  
  fmt.Printf("%d", a[n-1].longest)
}