Master Zhu and Chessboard

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Master Zhu has a rectangular board consisting of NN rows and MM columns. In the ii-th row, the squares from the column L_iL\_i to the column R_iR\_i inclusive are colored black, and all other squares are colored white. Additionally, it is known that L_iL_i+1L\_i \le L\_{i + 1} and R_iR_i+1R\_i \le R\_{i + 1}. Now Master Zhu is going to place some chess pieces on several black squares so that for each black square, there is at least one chess piece in its row or in its column.

Find the minimum number of chess pieces he should place.

입력

The first line of the input contains two integers NN and MM: the number of rows and columns (1N,M100)(1 \le N, M \le 100). Each of the next NN lines contains two integers L_iL\_i and R_iR\_i (1L_iR_iM1 \le L\_i \le R\_i \le M). It is guaranteed that L_iL_i+1L\_i \le L\_{i + 1} and R_iR_i+1R\_i \le R\_{i + 1}.

출력

Output the minimum number of chess pieces Master Zhu should place.