Did you know? Tulips were so valuable in the century that they caused an economic phenomenon known as Tulip Mania - some bulbs were worth more than houses.
A field of tulips is represented as an axis-aligned rectangle, with irrigation sprinklers placed on its four sides. These sprinklers spray a fertilizing solution over the field.
The Dutch farmer, Jakob, wants to determine how many tulips will ripen faster because they are planted in a special fertilized zone.
There are tulips planted at locations for . A tulip is considered to be in the fertilized zone if, together with the four corners of the rectangle, it forms
- two acute-angled triangles, and
- two obtuse-angled triangles.
Your task is to count how many tulips meet this condition.
Input data
The input file consists of:
- A line containing integers , .
- A line containing integers , .
- A line containing integers , .
- A line containing integers , .
- A line containing integer .
- lines, the -th of which consisting of integers , .
Output data
The output file must contain a single line consisting of integer , the number of tulips in the special zone.
Constraints and clarifications
- All points, including the rectangle's corners, lie within the geometric space .
- The rectangle is axis-aligned, that is, the sides of the rectangle are parallel to the axes.
- .
- All tulips are inside the rectangle. There is no tulip located on a side of the rectangle.
- All tulip locations are unique (there are no identical positions).
# | Points | Constraints |
---|---|---|
1 | 0 | Examples |
2 | 100 | No additional constraints |
Example 1
stdin
0 5
10 5
10 0
0 0
5
2 3
1 4
4 1
9 1
6 3
stdout
4
Explanation
In the following figures, the areas are covered with fertilizer, while the areas are not.
In the first sample case, the only tulip outside the fertilized area is located at position .
Example 2
stdin
0 35
35 35
35 0
0 0
10
17 8
16 5
32 27
18 32
8 18
17 30
14 19
5 11
2 32
2 11
stdout
4
Explanation
In the second sample case, the tulips inside the fertilized area are located at the points: , , ,
and .