#include<bits/stdc++.h>
using namespace std;
bool a[10010];
int num;
int kanshu;
int tou,wei;
int shushu=0;
int main(){
cin>>num;
cin>>kanshu;
for(int i=1;i<=kanshu;i++){
cin>>tou>>wei;
for(int j=tou;j<=wei;j++){
a[j]=1;
}
}
for(int i=0;i<num;i++){
if(a[i]==0) shushu++;
}
shushu++;
cout<<shushu;
return 0;
}