import strutils,sequtils
import algorithm,sets,lists,critbits,sequtils,intsets,strutils,tables,math,heapqueue,future,deques

let read = iterator: string {.closure.} =
  while true:
    for s in stdin.readLine.split:
      yield s

let N, K = read().parseInt

var ai = newSeq[int](N)
for i in 0..<N:
  let A = read().parseInt
  ai[i] = A

var memo = initTable[(int, int), int]()
proc solve(left, right: int): int =
  if left == right:
    return 0
  elif memo.contains((left, right)):
    return memo[(left, right)]
  
  var
    a = ai[left]
    is_ok = true
  for i in left+1..right:
    let diff = (ai[i] - a).abs
    if diff > K:
      is_ok = false
      break
    a = ai[i]
  
  if is_ok:
    memo[(left, right)] = 0
  elif right - left == 1:
    memo[(left, right)] = 1
  else:
    var cnt = high(int)
    for i in left+1..<right:
      let tmp = solve(left, i-1) + solve(i+1, right) + 1
      cnt = min(cnt, tmp)
    memo[(left, right)] = cnt

  return memo[(left, right)]

echo N - solve(0, N-1)
