Given horizontal lines and
vertical lines, count the number of squares in the grid. For example, a horizontal line could be
or
, etc. Furthermore, vertical lines could be
or
. The lines of the cartesian grid will never start at a negative position in both the y-axis and x-axis.
The whole boundary of the square has to be drawn. The inside of the square does not have to be empty.
Input Specification
The first line of input will contain 2 integers, and
.
The next line of input will contain integers
, indicating that the line
exists.
The next line of input will contain integers
, indicating that the line
exists.
Output Specification
Output the total number of squares.
Sample Input
3 4
0 1 3
1 2 4 8
Sample Output
3
There is one square, one
square, and one
square.
Comments