Ethan is an avid stock trader. In order to predict future stock prices, he performs technical analysis on stock charts by drawing trendlines. The chart is displayed as a grid with time on the x-axis and price on the y-axis. There are points, where the point is , indicating that at time , the stock price was . Adjacent points are then connected to form a line graph. That is, point is connected to points and .
The line connecting two points and where is considered to be a trendline when all points in the range are either all above/on the line or all below/on the line. Can you help Ethan find the number of different trendlines he can draw? Two trendlines are considered different if they start or end at different points.
For all subtasks:
The first line contains one integer .
The next lines contain two integers and .
Output the number of different trendlines that could be drawn.
Explanation for Sample Output
Notice that the line connecting points and is not a trendline.