During the summer, Vasya interned at the company «Yandex». In the final interview, he was given the following problem.
There is a rectangular matrix with n rows and m columns. The values in the cells are non-negative integers. The sums of the numbers in the rows are known as ri, and the sums of the numbers in the columns are known as cj, but the actual values in the cells are unknown. A cell in the a-th row and b-th column of the matrix has been selected, and the task is to determine how many possible values can be written in that cell.
However, since this is the final interview, the problem is designed to test whether the candidate believes everything they hear. In this problem, it is possible that a matrix with the given values of ri and cj does not exist. In that case, the answer to the problem is 0.
As you can understand, Vasya successfully solved this problem. Can you do it too?
Input
The first line contains two integers n and m, which represent the number of rows and columns in the matrix (1 ≤ n, m ≤ 103).
The second line contains two integers a and b, which represent the row and column number of the selected cell (1 ≤ a ≤ n, 1 ≤ b ≤ m). Rows are numbered from 1 to n, and columns are numbered from 1 to m.
The third line contains n integers r1, …, rn, separated by spaces, where ri is the sum of the numbers in the i-th row of the matrix (0 ≤ ri ≤ 109).
The fourth line contains m integers c1, …, cm, separated by spaces, where cj is the sum of the numbers in the j-th column of the matrix (0 ≤ cj ≤ 109).
Output
Output a single number, which represents the number of possible values in the selected cell.
Samples
input | output |
---|
1 2
1 1
15
5 10
| 1
|
2 2
2 2
10 15
12 13
| 11
|
Problem Author: Semyon Trifochkin
Problem Source: Ural School Programming Contest 2021