- Time limit: 2.00 s
- Memory limit: 512 MB
Uolevi has found two matrices and of size . Every element in both matrices is either or . They also have the following special property: if the element in is , then for all and such that and the element in is also .
Now Uolevi is wondering what happens if he multiplies with . Particularly he is interested in how many non-zero elements contains.
Can you help him to answer this question?
Input
In the first line you're given the integer .
The second line contains non-decreasing integers . These integers describe the matrix . For , let if , and otherwise one. It can be proven that every matrix with the given property can be presented this way.
The third line contains non-decreasing integers . These integers describe the matrix , in the same way as the integers describe .
Output
Output a single integer: the number of non-zero elements in .
Constraints
Example
Input:
3 2 2 3 0 1 3
Output:
5