eolymp
bolt
Try our new interface for solving problems
Problems

Leaf in the cage

Leaf in the cage

On a square piece of paper the size of \textbf{N}×\textbf{N} cells \textbf{K} drew different rectangles with the sides on the lines of the grid. Knowing the coordinates of pairs of opposite vertices of each rectangle in the rectangular coordinate system whose origin lezhit in one of the extreme points of the leaf, and the axes coincide with its sides, calculate how many pieces fall apart a piece of paper, if you make the cuts on each side of the rectangle. \includegraphics{https://static.e-olymp.com/content/ef/ef02acfcd6b8981ca79bdc4f2534fdf3ee86697c.jpg} \InputFile In the first runoff of \textbf{N} and \textbf{K}. The following \textbf{K} lines of four non-negative integers - the coordinates of two opposite vertices of each rectangle. All numeric values ​​are non-negative integers, not greater than \textbf{100}. \OutputFile The answer to the problem.
Time limit 1 second
Memory limit 64 MiB
Input example #1
8 3
2 2 5 6
3 3 8 1
6 4 4 8
Output example #1
7