p02537 ACL Beginner Contest - Flat Subsequence
You are given a sequence A_1, A_2, ..., A_N and an integer K.

Print the maximum possible length of a sequence B that satisfies the following conditions:

* B is a (not necessarily continuous) subsequence of A.
* For each pair of adjacents elements of B, the absolute difference of the elements is at most K.

Constraints

* 1 \leq N \leq 300,000
* 0 \leq A_i \leq 300,000
* 0 \leq K \leq 300,000
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N K
A_1
A_2
:
A_N


Output

Print the answer.

Example

Input

10 3
1
5
4
3
8
6
9
7
2
4


Output

7
```python
import typing
class SegTree:
    def __init__(self,
                 op: typing.Callable[[typing.Any, typing.Any], typing.Any],
                 e: typing.Any,
                 v: typing.Union[int, typing.List[typing.Any]]):
        self._op = op
        self._e = e

        if isinstance(v, int):
            v = [e] * v

        self._n = len(v)
        self._log = self._ceil_pow2(self._n)
        self._size = 1 << self._log
        self._d = [e] * (2 * self._size)

        for i in range(self._n):
            self._d[self._size + i] = v[i]
        for i in range(self._size - 1, 0, -1):
            self._update(i)
    
    def set(self, p: int, x: typing.Any) -> None:
        assert 0 <= p < self._n
        p += self._size
        self._d[p] = x
        for i in range(1, self._log + 1):
            self._update(p >> i)

    def prod(self, left: int, right: int) -> typing.Any:
        assert 0 <= left <= right <= self._n
        sml = self._e
        smr = self._e
        left += self._size
        right += self._size

        while left < right:
            if left & 1:
                sml = self._op(sml, self._d[left])
                left += 1
            if right & 1:
                right -= 1
                smr = self._op(self._d[right], smr)
            left >>= 1
            right >>= 1

        return self._op(sml, smr)

    def all_prod(self) -> typing.Any:
        return self._d[1]

    def _update(self, k: int) -> None:
        self._d[k] = self._op(self._d[2 * k], self._d[2 * k + 1])
    
    def _ceil_pow2(self, n: int) -> int:
        x = 0
        while (1 << x) < n:
            x += 1
        return x

N, K = map(int, input().split())
A = list(int(input()) for _ in range(N))
max_A = max(A)
seg = SegTree(max, -1, [0]*(max_A+1))
for v in A:
    l = max(0, v-K)
    r = min(max_A, v+K)
    seg.set(v, seg.prod(l, r+1)+1)
print(seg.all_prod())
```