#include<bits/stdc++.h>
using namespace std;
int main(){
int L,M,sum = 0;
cin>>L>>M;
vector<int> removed(L+1,0);
for(int i = 0;i<M;i++){
int a,b;
cin>>a>>b;
for(int j = a;j<=b;j++){
removed[j] = 1;
}
}
for(int i = 0;i<=L;i++){
sum+=removed[i];
}
cout<<L+1-sum;
}

京公网安备 11010502036488号