P12732 Stranger
Background
> I can confidently state the following because I have experienced this myself. A younger step-sister is nothing but a stranger.\
--Yuta Asamura
Description
Yuta and Saki sometimes run into each other at school. Since they are in different classes, they are usually in different places during lessons and only see each other when changing classrooms at the breaks.
At Suisei High School, there are a total of $n-1$ breaks in a day. During the $i$-th break, Yuta moves from the $y_i$-th floor to the $y_{i+1}$-th floor, while Saki moves from the $s_i$-th floor to the $s_{i+1}$-th floor. Assuming the break starts at time $i$ and ends at time $i+1$, their movements can be represented as line segments on a Cartesian coordinate system with time $t$ on the horizontal axis and height $h$ on the vertical axis. Specifically, Yuta's path is the line segment from point $(i, y_i)$ to $(i+1, y_{i+1})$, and Saki's path is the line segment from point $(i, s_i)$ to $(i+1, s_{i+1})$.
If they are at the same height at the same time, meaning if the aforementioned two line segments intersect, then the two will see each other. They may see each other on the stairs between floors, or at the start or end of their journey. In other words, the coordinates of the intersection point does not have to be an integer, and the intersection point can be at the endpoints of the segments, that is, if Yuta and Saki are in the same floor for class, i.e., $y_i = s_i$, then it is considered that they will meet each other during both the $(i-1)$-th break (if $i \ge 2$) and the $i$-th break (if $i \le n-1$).
They want to know during how many breaks they will see each other in total today.
Input Format
The first line contains an integer $n$ representing the number of class periods, with the number of breaks being $n-1$.
The second line is consisted of $n$ integers representing $y_1,\dots,y_n$.
The third line is consisted of $n$ integers representing $s_1,\dots,s_n$.
Output Format
Output a single integer indicating the number of encounters.
Explanation/Hint
#### Sample Explanation
During the first break, Yuta and Saki meet on the stairs between the $1$st and $2$nd floors.
During the second break, the two do not meet.
#### Constraints
For $20\%$ of the testdata, $y_i,s_i\leq2$.
For an additional $20\%$ of the testdata, all $y_i$-s are the same.
For an additional $20\%$ of the testdata, all $s_i$-s are the same.
For all of the testdata, $2\leq n\leq10$, $1\leq y_i,s_i\leq10$.