// use proconio::marker::Chars;
use proconio::{fastout, input};
// use std::cmp::{max, min};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n]
    };

    let mut base = 0;
    let mut v = vec![0; n];

    for i in 0..n {
        if v[i] == 0 {
            let mut count = 1;
            v[i] = count;
            base = v[i];
            for j in i + 1..n {
                if (base as i128 - a[j] as i128).abs() as usize <= k && v[j] <= count + 1 {
                    count += 1;
                    base = a[j];
                    v[j] = count;
                }
            }
        }
    }

    println!("{}", v.iter().max().unwrap());
}
