using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static void Main(string[] args)
    {
        var N = NextInt();
        var K = NextInt();
        var A = new int[N];
        for (int n = 0; n < N; n++)
        {
            A[n] = NextInt();
        }

        var dp = new int[N];
        for (int i = 0; i < N; i++)
        {
            dp[i] = Math.Max(dp[i], 1);
            for (int j = i + 1; j < N; j++)
            {
                if (Math.Abs(A[i] - A[j]) <= K)
                    dp[j] = Math.Max(dp[j], dp[i] + 1);
            }
        }
        Console.WriteLine(dp[N - 1]);
    }
}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{
}
