import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);

		int card = sc.nextInt();
		int gate = sc.nextInt();
		int min = 100000;
		int max = 0;

		int[] L = new int[gate];
		int[] R = new int[gate];
		for(int i = 0; i<gate; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		for(int i=0; i<gate; i++) {
				max = Math.max(L[i], max);
				min = Math.min(R[i], min);
		}
			int anser = Math.max((min-max)+1, 0);
			System.out.println(anser);
		}

	} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);

		int card = sc.nextInt();
		int gate = sc.nextInt();
		int min = 100000;
		int max = 0;

		int[] L = new int[gate];
		int[] R = new int[gate];
		for(int i = 0; i<gate; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		for(int i=0; i<gate; i++) {
				max = Math.max(L[i], max);
				min = Math.min(R[i], min);
		}
			int anser = Math.max((min-max)+1, 0);
			System.out.println(anser);
		}

	} Main public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);

		int card = sc.nextInt();
		int gate = sc.nextInt();
		int min = 100000;
		int max = 0;

		int[] L = new int[gate];
		int[] R = new int[gate];
		for(int i = 0; i<gate; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		for(int i=0; i<gate; i++) {
				max = Math.max(L[i], max);
				min = Math.min(R[i], min);
		}
			int anser = Math.max((min-max)+1, 0);
			System.out.println(anser);
		} main {
		Scanner sc =new Scanner(System.in);

		int card = sc.nextInt();
		int gate = sc.nextInt();
		int min = 100000;
		int max = 0;

		int[] L = new int[gate];
		int[] R = new int[gate];
		for(int i = 0; i<gate; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		for(int i=0; i<gate; i++) {
				max = Math.max(L[i], max);
				min = Math.min(R[i], min);
		}
			int anser = Math.max((min-max)+1, 0);
			System.out.println(anser);
		} Scanner sc =new Scanner(System.in); sc new Scanner(System.in) int card = sc.nextInt(); card sc.nextInt() sc.nextInt sc int gate = sc.nextInt(); gate sc.nextInt() sc.nextInt sc int min = 100000; min 100000 int max = 0; max 0 int[] L = new int[gate]; L new int[gate] gate int[] R = new int[gate]; R new int[gate] gate for(int i = 0; i<gate; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i<gate i gate 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 for(int i=0; i<gate; i++) {
				max = Math.max(L[i], max);
				min = Math.min(R[i], min);
		} int i=0; int i=0; i 0 i<gate i gate i++ i++ i {
				max = Math.max(L[i], max);
				min = Math.min(R[i], min);
		} {
				max = Math.max(L[i], max);
				min = Math.min(R[i], min);
		} max = Math.max(L[i], max) max Math.max(L[i], max) Math.max Math L[i] L i max min = Math.min(R[i], min) min Math.min(R[i], min) Math.min Math R[i] R i min int anser = Math.max((min-max)+1, 0); anser Math.max((min-max)+1, 0) Math.max Math (min-max)+1 (min-max) min max 1 0 System.out.println(anser) System.out.println System.out System System.out anser String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);

		int card = sc.nextInt();
		int gate = sc.nextInt();
		int min = 100000;
		int max = 0;

		int[] L = new int[gate];
		int[] R = new int[gate];
		for(int i = 0; i<gate; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		for(int i=0; i<gate; i++) {
				max = Math.max(L[i], max);
				min = Math.min(R[i], min);
		}
			int anser = Math.max((min-max)+1, 0);
			System.out.println(anser);
		}

	} public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);

		int card = sc.nextInt();
		int gate = sc.nextInt();
		int min = 100000;
		int max = 0;

		int[] L = new int[gate];
		int[] R = new int[gate];
		for(int i = 0; i<gate; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		for(int i=0; i<gate; i++) {
				max = Math.max(L[i], max);
				min = Math.min(R[i], min);
		}
			int anser = Math.max((min-max)+1, 0);
			System.out.println(anser);
		}

	} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);

		int card = sc.nextInt();
		int gate = sc.nextInt();
		int min = 100000;
		int max = 0;

		int[] L = new int[gate];
		int[] R = new int[gate];
		for(int i = 0; i<gate; i++) {
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
		}
		for(int i=0; i<gate; i++) {
				max = Math.max(L[i], max);
				min = Math.min(R[i], min);
		}
			int anser = Math.max((min-max)+1, 0);
			System.out.println(anser);
		}

	}