title: P1047校门外的树 categories:
#include<bits/stdc++.h>
using namespace std;
int R[10005];
int main(){
int l,m,a,b,c;
cin>>l>>m;
for(int i=0;i<=l;i++){
R[i]=1;
}
for(int i=0;i<m;i++){
cin>>a>>b;
for(int j=a;j<=b;j++){
R[j]=0;
}
}
for(int i=0;i<=l;i++){
if(R[i])c++;
}
cout<<c<<endl;
return 0;
}
//by luisleee