Doctor Y, always eager to further his research in the field of boxology, is observing a family of boxen in their natural habitat - a barrel of wine. He has noticed that in addition to the rectangular, two-dimensional boxen, there are almost imperceptible points floating on the surface of the wine. He reasons that these must be baby boxen - also known as boxlings.
Curious as to the customs of box families, Doctor Y wishes to count how many boxlings are floating on top of boxen. From his top-down view of the barrel, he has divided the surface of the wine into a two-dimensional Cartesian plane, and noted the positions of all the boxen and boxlings. Each box occupies a rectangular region parallel to the axes of the plane, with its lower-left corner at and its upper-right corner at , such that and . Doctor Y has observed that boxen sometimes overlap one another. Each boxling is so small that it occupies only a single point on the plane, with -coordinate and -coordinate , such that .
Having recorded the locations of all the life forms on the surface of the wine, Doctor Y is interested in counting exactly how many boxlings are floating on top of at least one box. Note that if a boxling is on the very edge or corner of a box, it counts as being on top. Also note that two boxlings can occupy the exact same locations, and that they should be counted separately.
With so many boxen and boxlings living in this wine barrel, Doctor Y doesn't feel like sitting there and counting them all by hand, crazy though he is. As such, he wants you to write a program to, given the locations of all the boxen and boxlings, count the number of boxlings that are floating on top of at least one box. Don't worry; your hard work will surely lead to exciting discoveries in the field of boxology.
Input Specification
Line 1: Two integers - and
The next lines: Four integers - , , and
The next lines: Two integers - and
Output Specification
A single integer - the number of boxlings that are on top of at least one box.
Sample Input
5 10
-1 -1 2 5
4 -3 5 3
1 2 4 4
5 -6 8 -4
1 -2 8 0
1 4
5 4
2 2
3 1
6 -5
5 -1
3 -3
-1 -2
-1 -1
2 -1
Sample Output
6
Explanation
Below is a top-down view of the surface of the wine:
The coloured-in squares are the boxen, the red dots are boxlings that are on top of at least one box, and the blue dots are the other boxlings. Counting the red dots, it can be seen that there are six of them.
Comments