时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
There are

people standing in a line, numbered from

to

from left to right. Among these people, there are

pairs of friends.
Define an interval
![[l,r] [l,r]](https://www.nowcoder.com/equation?tex=%5Ctextstyle%20%5Bl%2Cr%5D)
(

) as friendly if and only if every pair of people within the interval are friends.
How many friendly intervals are there?
输入描述:
The first line contains two integers

and

(

), representing the number of people and the number of pairs of friends, respectively.
The next

lines each contain two integers

and

(

), representing a pair of friends.
It is guaranteed that there are no duplicate friend pairs in the input.
输出描述:
Output a single integer representing the number of friendly intervals.
示例1
输入
复制
5 9
2 3
1 3
4 5
3 5
1 2
2 4
1 5
1 4
2 5