Problem9761--ABC199 —— B - Intersection

9761: ABC199 —— B - Intersection

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

You are given sequences of length $N$ each: $A = (A_1, A_2, A_3, \dots, A_N)$ and $B = (B_1, B_2, B_3, \dots, B_N)$.  
Find the number of integers $x$ satisfying the following condition:

-   $A_i \le x \le B_i$ holds for every integer $i$ such that $1 \le i \le N$.

Input

Input is given from Standard Input in the following format:

```
$N$
$A_1$ $A_2$ $A_3$ $\dots$ $A_N$
$B_1$ $B_2$ $B_3$ $\dots$ $B_N$
```

Output

Print the answer.

Constraints

-   $1 \le N \le 100$
-   $1 \le A_i \le B_i \le 1000$
-   All values in input are integers.

Sample 1 Input

2
3 2
7 5

Sample 1 Output

3
x must satisfy both 3≤x≤7 and 2≤x≤5.
There are three such integers: 3, 4, and 5.

Sample 2 Input

3
1 5 3
10 7 3

Sample 2 Output

0
There may be no integer x satisfying the condition.

Sample 3 Input

3
3 2 5
6 9 8

Sample 3 Output

2

Source/Category