校门外的树
#include<iostream>
#include<algorithm>using namespace std;typedef pair<int, int> PII;
#define x first
#define y secondconst int N = 110;int n, m;
PII q[N];int main()
{cin >> n >> m;for(int i=0; i<m; i++) cin >> q[i].x >> q[i].y;sort(q, q+m);// 将所有区间按照起始点的坐标从小到大排序,为相交区间合并做准备int sum = 0;int start = 0, end = -1;for(int i=0; i<m; i++)if(end < q[i].x){sum += end - start + 1;start = q[i].x, end = q[i].y;}else end = max(end, q[i].y); // 相交区间合并sum += end - start + 1;cout << n + 1 - sum << endl;return 0;
}