using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var array = new int[n[0]];
        var list = new List<int>();
        array[0] = int.Parse(ReadLine());
        var before = array[0];
        var count = 1;
        for(int i = 1; i < n[0]; i++)
        {
            array[i] = int.Parse(ReadLine());
            if(Abs(before - array[i]) <= n[1])
            {
                count++;
                before = array[i];
            }
            else
            {
                list.Add(i);
            }
        }
        for(int i = 0; i < list.Count && count < n[0] - list[i]; i++)
        {
            var c = 1;
            before = array[list[i]];
            for(int j = list[i] + 1; j < n[0]; j++)
            {
                if(Abs(before - array[j]) <= n[1])
                {
                    c++;
                    before = array[j];
                }
            }
            count = Max(count, c);
        }
        WriteLine(count);
    }
}
