using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (n, k) = (nk[0], nk[1]);
        var seqA = Console.In.ReadToEnd().Split().Where(x => !string.IsNullOrWhiteSpace(x)).Select(x => int.Parse(x)).ToArray();

        var max = Dfs(k, seqA, -1, 0);

        Console.WriteLine(max);
    }

    static int Dfs(int k, Span<int> xs, int t, int length)
    {
        if (xs.Length < 1)
        {
            return length;
        }

        var d = t < 0 ? 0 : Math.Abs(xs[0] - t);
        var l = Dfs(k, xs[1..], t, length);
        if (d > k)
        {
            return l;
        }

        return Math.Max(l, Dfs(k, xs[1..], xs[0], length + 1));
    }
}
