#P12732. 外人

外人

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 n1n-1 breaks in a day. During the ii-th break, Yuta moves from the yiy_i-th floor to the yi+1y_{i+1}-th floor, while Saki moves from the sis_i-th floor to the si+1s_{i+1}-th floor. Assuming the break starts at time ii and ends at time i+1i+1, their movements can be represented as line segments on a Cartesian coordinate system with time tt on the horizontal axis and height hh on the vertical axis. Specifically, Yuta's path is the line segment from point (i,yi)(i, y_i) to (i+1,yi+1)(i+1, y_{i+1}), and Saki's path is the line segment from point (i,si)(i, s_i) to (i+1,si+1)(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., yi=siy_i = s_i, then it is considered that they will meet each other during both the (i1)(i-1)-th break (if i2i \ge 2) and the ii-th break (if in1i \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 nn representing the number of class periods, with the number of breaks being n1n-1.

The second line is consisted of nn integers representing y1,,yny_1,\dots,y_n.

The third line is consisted of nn integers representing s1,,sns_1,\dots,s_n.

Output Format

Output a single integer indicating the number of encounters.

3
1 2 3
3 1 2

1

Hint

Sample Explanation

During the first break, Yuta and Saki meet on the stairs between the 11st and 22nd floors.

During the second break, the two do not meet.

Constraints

For 20%20\% of the testdata, yi,si2y_i,s_i\leq2.

For an additional 20%20\% of the testdata, all yiy_i-s are the same.

For an additional 20%20\% of the testdata, all sis_i-s are the same.

For all of the testdata, 2n102\leq n\leq10, 1yi,si101\leq y_i,s_i\leq10.