by sheet of paper. He has two tools, a pair of scissors and a paper cutter. The paper cutter will always cut the whole sheet (from one end to another). With the scissors though, he can choose how deep to cut the paper. Unfortunately, the paper cutter is set up to only cut vertically, and thus, he will only use the scissors to cut horizontally. Before he actually cuts the paper, he wants to know how many pieces of paper he will end up with after the cuts.
is doing some arts and crafts. Hypothetically speaking, he is cutting horizontal and vertical lines on anA piece of paper is freed when all 4 sides of the rectangular area are cut (including the original edges of the paper). He may cut multiple times at the same spot. When this happens, infinitely small pieces of paper will not be created, i.e., the longer cut takes precedence.
Input Specification
Three space separated integers, , and .
lines follow, of the form:
h s d
a horizontal cut of depth , starting above the bottom of the piece of paper.v s
a vertical cut from the top to the bottom, starting to the right of the left edge of the sheet.
Constraints
Subtask 1 [5%]
Subtask 2 [5%]
Subtask 3 [90%]
Note: fast input may be required.
Output Specification
The number of pieces of paper that
will end up with after performing the cuts.Sample Input
3 4 6
h 3 4
h 1 3
v 2
Sample Output
5
Explanation for Sample Output
The cuts are shown in the picture below. The gold numbers show the pieces of paper.
Comments
Is it possible that he will cut at a non-integer spot?
No