/
NOIP2005复赛 普及组 第2题 校门外的树(枚举)
http://noi.openjudge.cn/ch0106/06/
https://www.luogu.org/problemnew/show/P1047
https://bbs.codeaha.com/problem-12002.html
/
#include
using namespace std;

int road[10001];

int main()
{
int l, m, s, e, cnt = 0;
cin >> l >> m;

for (int i = 0; i <= l; i++)
    road[i] = 1;

for (int i = 0; i < m; i++)
{
    cin >> s >> e;
    for (int j = s; j <= e; j++)  //start end
        road[j] = 0;
}

for (int i = 0; i <= l; i++)
    if (road[i] == 1)
        cnt++;

cout << cnt; 
return 0;

}