#![allow(unused_imports)]
use proconio::marker::*;
use proconio::{fastout, input};

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

    let res = solve(n, k, &ar);
    println!("{}", res);
}

fn solve(n: usize, k: isize, ar: &[isize]) -> usize {
    let mut max = 0;
    for i in 0..n {
        let mut num = ar[i];
        let mut c = 1;
        if n - i < max {
            break;
        }
        for p in i + 1..n {
            if (num - ar[p]).abs() <= k {
                c += 1;
                num = ar[p];
            }
        }
        if max < c {
            max = c;
        }
    }
    max
}
