#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL a[114514];
int main(){
LL m, l;
cin >> l;
for(int i = 1; i <= l; i++)
a[i] = 0;
cin >> m;
int r,f;
for(int i = 1; i <= m; i++){
cin >> r >> f;
for(int j = r; j <= f; j++){
a[j] = 1;
}
}
int t = 0;
for(int i = 1; i <= l; i++)
if(a[i] != 1) t++;
cout<<++t;
return 0;
}