ALEAVE - Annual leave calculator

In a large organisation, people need to keep track of annual leave. Employees will submit their leave requests, and these will be recorded. However, leave requests might overlap.

A leave request has the form

startday endday

where startday and endday represent days of the year, falling between 1 and 366. Start day is the first day of the leave period (so counts as leave). End day is the day the leave ends - that is, the first day back in work.

An employee will make any number of leave requests in a year, which might mistakenly overlap. At the end of the year you will need to calculate the total days leave for an employee based upon their requests.

Requests can come out-of-order.

Input

Input will be the number of leave requests, followed by the set of leave requests, one per line.

Output

Output should be the total days leave requested for the employee in question

Example

Input:
3
140 145
120 123
121 122

Output: 8

Added by:handee
Date:2020-06-10
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.