import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
boolean[] b = new boolean[sc.nextInt() + 1];
int t = sc.nextInt(), ans = 0;
while(t-- > 0) {
int start = sc.nextInt(), end = sc.nextInt();
for(int i = start; i <= end; ++i)
b[i] = true;
}
for(int i = 0; i < b.length; ++i)
if(!b[i]) ans++;
System.out.println(ans);
sc.close();
}
}