import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T
import Data.Bits

main :: IO ()
main = do
  let
    m = 300000 :: Int
  [n, k] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    f :: [Int] -> Tree
    f = foldl step tree0
      where
        step :: Tree -> Int -> Tree
        step t x = modify (m + 1, t) x (y + 1)
          where
            y = query (m + 1, t) (max 0 (x - k), min m (x + k) + 1) :: Int
        tree0 = fromList . replicate (m + 1) $ 0 :: Tree
  as <- map unsafeTextToInt . T.lines <$> T.getContents :: IO [Int]
  print . extract . f $ as

data Tree = Node Int (Maybe Tree, Maybe Tree)

extract :: Tree -> Int
extract (Node x _) = x

unsafeLeft :: Tree -> Tree
unsafeLeft (Node _ (Just t, _)) = t

unsafeRight :: Tree -> Tree
unsafeRight (Node _ (_, Just t)) = t

singleton :: Int -> Tree
singleton = flip Node (Nothing, Nothing)

fromList :: [Int] -> Tree
fromList = unsafeLeft . head . rec . map singleton
  where
    rec :: [Tree] -> [Tree]
    rec (t : t' : ts) = rec (Node (extract t `max` extract t') (Just t, Just t') : rec ts)
    rec (t : _) = [Node (extract t) (Just t, Nothing)]
    rec _ = []

modify :: (Int, Tree) -> Int -> Int -> Tree
modify (1, Node x lr) _ d = Node (x `max` d) lr
modify (n, Node x (Just l, r)) i d | i < nl    = Node (x `max` d) (Just (modify (nl, l) i d), r)
  where
    nl = flip shiftR 1 . bit $ finiteBitSize n - countLeadingZeros n :: Int
modify (n, Node x (l, Just r)) i d = Node (x `max` d) (l, Just (modify (n - nl, r) (i - nl) d))
  where
    nl = flip shiftR 1 . bit $ finiteBitSize n - countLeadingZeros n :: Int

query :: (Int, Tree) -> (Int, Int) -> Int
query (n, t) (i, j) | i == 0 && n <= j = extract t
                    | j <= nl          = query (nl, unsafeLeft t) (i, j)
                    | nl <= i          = query (n - nl, unsafeRight t) (i - nl, j - nl)
                    | otherwise        = query (nl, unsafeLeft t) (i, nl) `max` query (n - nl, unsafeRight t) (nl, j - nl)
  where
    nl = flip shiftR 1 . bit $ finiteBitSize n - countLeadingZeros n :: Int

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}
