human
Emuskald is an avid horticulturist and owns the world's longest greenhouse — it is effectively infinite in length.

Over the years Emuskald has cultivated n plants in his greenhouse, of m different plant species numbered from 1 to m. His greenhouse is very narrow and can be viewed as an infinite line, with each plant occupying a single point on that line.

Emuskald has discovered that each species thrives at a different temperature, so he wants to arrange m - 1 borders that would divide the greenhouse into m sections numbered from 1 to m from left to right with each section housing a single species. He is free to place the borders, but in the end all of the i-th species plants must reside in i-th section from the left.

Of course, it is not always possible to place the borders in such way, so Emuskald needs to replant some of his plants. He can remove each plant from its position and place it anywhere in the greenhouse (at any real coordinate) with no plant already in it. Since replanting is a lot of stress for the plants, help Emuskald find the minimum number of plants he has to replant to be able to place the borders.

Input

The first line of input contains two space-separated integers n and m (1 ≤ n, m ≤ 5000, n ≥ m), the number of plants and the number of different species. Each of the following n lines contain two space-separated numbers: one integer number si (1 ≤ si ≤ m), and one real number xi (0 ≤ xi ≤ 109), the species and position of the i-th plant. Each xi will contain no more than 6 digits after the decimal point.

It is guaranteed that all xi are different.
there is at least one plant of each species.
the plants are given in order "from left to the right", that is in the ascending order of their xi coordinates (xi < xi + 1, 1 ≤ i < n).

Output

Output a single integer — the minimum number of plants to be replanted.

Examples

Input

3 2
2 1
1 2.0
1 3.100

Output

1

Input

3 3
1 5.0
2 5.5
3 6.0

Output

0

Input

6 3
1 14.284235
2 17.921382
1 20.328172
3 20.842331
1 25.790145
1...
Using python can you solve the prior task?
assistant
#Here is Python program to find the minimum number of plants he has to replant to be able to place the borders.

from sys import stdin

rints = lambda: [int(x) for x in stdin.readline().split()]
rfloats = lambda: [float(x) for x in stdin.readline().split()]
arr_2d = lambda n: [rfloats() for i in range(n)]

class max_segmenttree:
    def __init__(self, arr, n):
        self.tree, self.n = [0] * (2 * n), n
        # build tree
        if arr:
            for i in range(2 * n - 1, 0, -1):
                if i >= n:
                    self.tree[i] = arr[i - n]
                else:
                    self.tree[i] = max(self.tree[i << 1], self.tree[(i << 1) + 1])

    # get interval[l,r)
    def query(self, l, r):
        res = 0
        l += self.n
        r += self.n
        while l < r:
            if l & 1:
                res = max(self.tree[l], res)
                l += 1

            if r & 1:
                r -= 1
                res = max(self.tree[r], res)

            l >>= 1
            r >>= 1

        return res

    def update(self, ix, val):
        ix += self.n

        # set new value
        self.tree[ix] = val

        # move up
        while ix > 1:
            self.tree[ix >> 1] = max(self.tree[ix], self.tree[ix ^ 1])
            ix >>= 1

n, m = rints()
a, tree = arr_2d(n), max_segmenttree([], m + 1)

for i in range(n):
    tree.update(int(a[i][0]), tree.query(0, int(a[i][0]) + 1) + 1)

print(n - tree.query(0, m + 1))