With the CCC coming up soon,
realizes that she is a bit underprepared! She decides to watch some YouTube tutorials about different algorithms! She comes to the conclusion that the more tutorials she watches, the better her score will be in the CCC. To achieve a high score, she decides to watch multiple videos at the same time!Her screen can be split into rows and columns of small windows. With some help from her friends, she comes up with a list of tutorials to watch, as well as the most important minute, in the video, for the window on the th row and th column. However, realizes that she cannot focus on more than two things at once!
To solve this issue, she decides to delay watching some videos for some number of minutes so that no two important minutes overlap. She wants to know the number of tutorials that she must delay such that she can study for the CCC without losing focus!
Constraints
Input Specification
The first line will contain integer , representing the number of rows, and , representing the number of columns.
The next lines will contain numbers, representing the most important minute in the video.
Output Specification
Print out the number of tutorials that must be delayed such that no two important minutes overlap.
Sample Input
3 3
1 2 3
4 2 6
9 100 12479
Sample Output
1
Comments