#include <cstdio> #include<iostream> #include<vector> using namespace std; int main() { int L, M; scanf("%d%d", &L, &M); vector<int> vec(L+1); //0~L vector vec(0)有树 vec(1)无树 for (int i = 0; i < M; ++i) { int left, right; scanf("%d%d", &left, &right); for (int j = left; j <= right; ++j) { vec[j] = 1; } } int treenum; vector<int>::iterator it; for (it = vec.begin(); it != vec.end(); ++it) { if (*it == 0) treenum++; } printf("%d", treenum); return 0; }