import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] L = new int[M];
		int[] R = new int[M];
		for( int i=0; i<M; i++ ){
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		Arrays.sort(L);
		Arrays.sort(R);
		int ans = 0;
		if( R[0]-L[M-1]>=0 ){
			ans = R[0]-L[M-1]+1;
		}
		System.out.println(ans);
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] L = new int[M];
		int[] R = new int[M];
		for( int i=0; i<M; i++ ){
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		Arrays.sort(L);
		Arrays.sort(R);
		int ans = 0;
		if( R[0]-L[M-1]>=0 ){
			ans = R[0]-L[M-1]+1;
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] L = new int[M];
		int[] R = new int[M];
		for( int i=0; i<M; i++ ){
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		Arrays.sort(L);
		Arrays.sort(R);
		int ans = 0;
		if( R[0]-L[M-1]>=0 ){
			ans = R[0]-L[M-1]+1;
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] L = new int[M];
		int[] R = new int[M];
		for( int i=0; i<M; i++ ){
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		Arrays.sort(L);
		Arrays.sort(R);
		int ans = 0;
		if( R[0]-L[M-1]>=0 ){
			ans = R[0]-L[M-1]+1;
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc int[] L = new int[M]; L new int[M] M int[] R = new int[M]; R new int[M] M for( int i=0; i<M; i++ ){
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		} int i=0; int i=0; i 0 i<M i M i++ i++ i {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		} {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		} L[i] = sc.nextInt() L[i] L i sc.nextInt() sc.nextInt sc R[i] = sc.nextInt() R[i] R i sc.nextInt() sc.nextInt sc Arrays.sort(L) Arrays.sort Arrays L Arrays.sort(R) Arrays.sort Arrays R int ans = 0; ans 0 if( R[0]-L[M-1]>=0 ){
			ans = R[0]-L[M-1]+1;
		} R[0]-L[M-1]>=0 R[0]-L[M-1] R[0] R 0 L[M-1] L M-1 M 1 0 {
			ans = R[0]-L[M-1]+1;
		} ans = R[0]-L[M-1]+1 ans R[0]-L[M-1]+1 R[0]-L[M-1] R[0] R 0 L[M-1] L M-1 M 1 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] L = new int[M];
		int[] R = new int[M];
		for( int i=0; i<M; i++ ){
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		Arrays.sort(L);
		Arrays.sort(R);
		int ans = 0;
		if( R[0]-L[M-1]>=0 ){
			ans = R[0]-L[M-1]+1;
		}
		System.out.println(ans);
	}
} public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] L = new int[M];
		int[] R = new int[M];
		for( int i=0; i<M; i++ ){
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		Arrays.sort(L);
		Arrays.sort(R);
		int ans = 0;
		if( R[0]-L[M-1]>=0 ){
			ans = R[0]-L[M-1]+1;
		}
		System.out.println(ans);
	}
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] L = new int[M];
		int[] R = new int[M];
		for( int i=0; i<M; i++ ){
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		Arrays.sort(L);
		Arrays.sort(R);
		int ans = 0;
		if( R[0]-L[M-1]>=0 ){
			ans = R[0]-L[M-1]+1;
		}
		System.out.println(ans);
	}
}
