
import Control.Monad
import Data.List

solveSub a [] k = [a]
solveSub a (b:s) k
    | abs (a - b) <= k = a : (solveSub b (s) k)
    | otherwise = (solveSub a (s) k)

solve [] k = []
solve (a:s) k = (length (solveSub a s k)) : (solve s k)


main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    ass <- replicateM n (map read . words <$> getLine) :: IO [[Int]]
    let as = (concat ass)
    print $ maximum $ solve as k