Master Zhu and Chessboard
면접 대비시간 제한1초메모리 제한512 MB
각 행의 검은 구간 [Li, Ri]가 오른쪽으로 밀리거나 포함되도록 주어질 때, 모든 검은 칸이 같은 행이나 열에 놓인 말과 겹치도록 하는 최소 말의 수를 구한다.
문제
Master Zhu has a rectangular board consisting of rows and columns. In the -th row, the squares from the column to the column inclusive are colored black, and all other squares are colored white. Additionally, it is known that and . 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 and : the number of rows and columns . Each of the next lines contains two integers and (). It is guaranteed that and .
출력
Output the minimum number of chess pieces Master Zhu should place.