#include <iostream>
#include<vector>
using namespace std;
int main() {
int L, M, boxmin, boxmax,n = 1;
cin >> L >> M;
std::vector<int>tree(L, 1);
while (M > 0) {
cin >> boxmin >> boxmax;
for(int i = boxmin-1;i<boxmax;++i){
tree[i]=0;
}
M--;
}
for(int j = 0;j<L;j++){
if(tree[j]==1){
n+=1;
}
}
std::cout<<n<<std::endl;
}

京公网安备 11010502036488号