A 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,
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