The MAPS team has been working hard to create problems for the MAPS Beginner Competition.
Currently, there are team members working on problem creation. In the final team meeting before the competition, which starts at time 1 and ends at time
, each member
is assigned a time interval
, during which they present their problems to Indra (a.k.a. the big boss). Here,
and
are natural numbers.
Unfortunately, Parsa has forgotten the exact time slot in which he was supposed to present his problems. However, he noticed an important rule in the meeting handbook: for every pair of team members, there must be at least one point during the meeting where both are presenting simultaneously.
Now, Parsa wonders how many possible time intervals he could have had for his presentation while still satisfying this rule — meaning that for every other team member, there exists at least one time point
within
where they are also presenting.
Note that:
- Intervals can be 0-length ([1, 1] is a valid interval).
- Two intervals overlap, even if their intersection is a singular point in time ([1, 2] and [2, 3] overlap).
Input
The first line of input contains and
: the number of team members including Parsa and how long the meeting lasted.
The next lines each contain two integers
which are the intervals the
th person is presenting.
Output
Print the number of ways Parsa can choose an interval which holds the rule.
Constraints
Example 1
Input
2 4
3 4
Output
7
Example 2
Input
2 2
1 1
Output
2
Comments