import java.util.*;
class Main{
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
int ans=in.nextInt();
int a[]=new int [ans+1];
int m=in.nextInt();
for(int i=0;i<m;i) {
int l=in.nextInt();
int r=in.nextInt();
for(int j=l;j<=r;j) {
a[j]=1;
}
}
for(int i=0;i<a.length;i++) {
if(a[i]==1) {
ans-=1;
}
}
System.out.println(ans+1);
}
}