#include <cstring>
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iomanip>
using namespace std;
const int maxL = 10010;
const int maxM = 110;
int main() {
int l, m;
cin >> l >> m;
bool trees[maxL];
for(int i = 0; i <= l; i++) {
trees[i] = true;
}
int start, stop;
for(int i = 0; i < m; i++) {
cin >> start >> stop;
for(int j = start; j <= stop; j++) {
trees[j] = false;
}
}
int cnt = 0;
for(int i = 0; i <= l; i++) {
if(trees[i]) {
cnt++;
}
}
cout << cnt << endl;
return 0;
}
这题什么都别想,写暴力就好。