Task
The mountains around Pisa are a well known hiking destination, with a peculiar terrain shape. In particular, you are interested in a rectangular area of square meters, subdivided into square cells, each with an area of a square meter.
Those cells are uniquely identified by their distance from the top and the left sides of the rectangle, with cell being at a distance of meters from the top of the map and meters from the left side of the rectangle.
Each cell has an altitude of meters, described by two arrays of integers and : .
A peak is a cell that has a strictly higher altitude than all the cells that share a side with it.
How many are there?
Input data
The input file consists of:
- a line containing integers , .
- a line containing the integers .
- a line containing the integers .
Output data
The output file must contain a single line consisting of 64-bit integer , the number of peaks in the rectangular area.
Constraints and clarifications
- .
- for each .
- for each .
# | Points | Constraints |
---|---|---|
1 | 0 | Examples. |
2 | 16 | |
3 | 33 | |
4 | 51 | No additional limitations. |
Example 1
stdin
1 5
7
4 6 8 5 1
stdout
1
Explanation
In the first sample case, the altitude of the cells is depicted below, with peaks highlighted in red.
Example 2
stdin
4 5
3 2 8 4
8 5 6 1 3
stdout
6
Explanation
In the second sample case, the altitude of the cells is depicted below, with peaks highlighted in red.