Classic 2D paintings are boring. That is why Sakurako decided to paint a painting which consists of 10^{100} dots that are positioned on a single line.
Initially, she wanted to paint some points with different colors.
For each color , she chose a segment of points numbered from l_i to r_i that she wanted to paint.
After you saw that, you argued that no point should be painted in more than one color.
Since Sakurako is stubborn, she decided that she would do exactly one of the following for each color (1\le i \le n):
Remove color completely (thus, no point is colored in color ).
Choose segment [x_i,y_i] such that l_i\le x_i\le y_i\le r_i and paint those points in color .
Sakurako is trying to maximize the total amount of points that are colored, if no point should be painted in more than one color.
Since she is busy with preparations, she asked you to determine the maximal amount of points that can be colored.
Point is said to be painted in color if x_i \le q\le y_i.
The first line contains one integer (1\le n\le 10^5) — the amount of colors that Sakurako initially chose.
Each of the next lines contains two integers l_i and r_i (0\le l_i\le r_i\le10^{15}).
Output the maximal amount of points that can be colored.
Example 1
One of the options to achieve seven is:
First color. Choose x=1 and y=1.
Second color. Choose x=4 and y=4.
Third color. Choose x=5 and y=8.
Fourth color. Choose x=3 and y=3.
Fifth color. Remove it.
In this problem, there are conditional blocks. If your solution works correctly for certain constraints, it will receive a certain number of points. Note that testing is going test by test, but not by blocks.
( points): l_i,r_i \le 10^{7};
( points): without additional constraints.