CF269B Greenhouse Effect
Description
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 Format
The first line of input contains two space-separated integers $ n $ and $ m $ ( $ 1
Output Format
Output a single integer — the minimum number of plants to be replanted.
Explanation/Hint
In the first test case, Emuskald can replant the first plant to the right of the last plant, so the answer is 1.
In the second test case, the species are already in the correct order, so no replanting is needed.