import java.io.*;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

        String[] lines = in.readLine().split(" ");
        final int n = Integer.parseInt(lines[0]);
        final int m = Integer.parseInt(lines[1]);

        int lc, rc;
        int[] table = new int[n+2];
        for (int i = 0; i < m; i++) {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        }

        for (int i = 0; i < n; i++) {
          table[i+1] += table[i];
        }

        int cnt = 0;
        for (int i : table) {
          if(i == m) cnt++;
        }

        final int ans = cnt;
        out.println(ans);
        out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
} import java.io.*; io.* java public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

        String[] lines = in.readLine().split(" ");
        final int n = Integer.parseInt(lines[0]);
        final int m = Integer.parseInt(lines[1]);

        int lc, rc;
        int[] table = new int[n+2];
        for (int i = 0; i < m; i++) {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        }

        for (int i = 0; i < n; i++) {
          table[i+1] += table[i];
        }

        int cnt = 0;
        for (int i : table) {
          if(i == m) cnt++;
        }

        final int ans = cnt;
        out.println(ans);
        out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
} Main public static void main(String[] args) {
    new Main().run();
  } main {
    new Main().run();
  } new Main().run() new Main().run new Main() String[] args args private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

        String[] lines = in.readLine().split(" ");
        final int n = Integer.parseInt(lines[0]);
        final int m = Integer.parseInt(lines[1]);

        int lc, rc;
        int[] table = new int[n+2];
        for (int i = 0; i < m; i++) {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        }

        for (int i = 0; i < n; i++) {
          table[i+1] += table[i];
        }

        int cnt = 0;
        for (int i : table) {
          if(i == m) cnt++;
        }

        final int ans = cnt;
        out.println(ans);
        out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    }
  } run {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

        String[] lines = in.readLine().split(" ");
        final int n = Integer.parseInt(lines[0]);
        final int m = Integer.parseInt(lines[1]);

        int lc, rc;
        int[] table = new int[n+2];
        for (int i = 0; i < m; i++) {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        }

        for (int i = 0; i < n; i++) {
          table[i+1] += table[i];
        }

        int cnt = 0;
        for (int i : table) {
          if(i == m) cnt++;
        }

        final int ans = cnt;
        out.println(ans);
        out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    }
  } try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

        String[] lines = in.readLine().split(" ");
        final int n = Integer.parseInt(lines[0]);
        final int m = Integer.parseInt(lines[1]);

        int lc, rc;
        int[] table = new int[n+2];
        for (int i = 0; i < m; i++) {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        }

        for (int i = 0; i < n; i++) {
          table[i+1] += table[i];
        }

        int cnt = 0;
        for (int i : table) {
          if(i == m) cnt++;
        }

        final int ans = cnt;
        out.println(ans);
        out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    } catch(IOException e) {
      System.err.println(e);
    } IOException e {
      System.err.println(e);
    } System.err.println(e) System.err.println System.err System System.err e {

        String[] lines = in.readLine().split(" ");
        final int n = Integer.parseInt(lines[0]);
        final int m = Integer.parseInt(lines[1]);

        int lc, rc;
        int[] table = new int[n+2];
        for (int i = 0; i < m; i++) {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        }

        for (int i = 0; i < n; i++) {
          table[i+1] += table[i];
        }

        int cnt = 0;
        for (int i : table) {
          if(i == m) cnt++;
        }

        final int ans = cnt;
        out.println(ans);
        out.flush();
    } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)) BufferedReader in = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) PrintWriter out = new PrintWriter(System.out) PrintWriter out = new PrintWriter(System.out) new PrintWriter(System.out) String[] lines = in.readLine().split(" "); lines in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " final int n = Integer.parseInt(lines[0]); n Integer.parseInt(lines[0]) Integer.parseInt Integer lines[0] lines 0 final int m = Integer.parseInt(lines[1]); m Integer.parseInt(lines[1]) Integer.parseInt Integer lines[1] lines 1 int lc lc rc; rc int[] table = new int[n+2]; table new int[n+2] n+2 n 2 for (int i = 0; i < m; i++) {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        } {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        } lines = in.readLine().split(" ") lines in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " lc = Integer.parseInt(lines[0]) lc Integer.parseInt(lines[0]) Integer.parseInt Integer lines[0] lines 0 rc = Integer.parseInt(lines[1]) rc Integer.parseInt(lines[1]) Integer.parseInt Integer lines[1] lines 1 table[lc]   += 1 table[lc] table lc 1 table[rc+1] -= 1 table[rc+1] table rc+1 rc 1 1 for (int i = 0; i < n; i++) {
          table[i+1] += table[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
          table[i+1] += table[i];
        } {
          table[i+1] += table[i];
        } table[i+1] += table[i] table[i+1] table i+1 i 1 table[i] table i int cnt = 0; cnt 0 for (int i : table) {
          if(i == m) cnt++;
        } int i table {
          if(i == m) cnt++;
        } {
          if(i == m) cnt++;
        } if(i == m) cnt++; i == m i m cnt++ cnt final int ans = cnt; ans cnt out.println(ans) out.println out ans out.flush() out.flush out public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

        String[] lines = in.readLine().split(" ");
        final int n = Integer.parseInt(lines[0]);
        final int m = Integer.parseInt(lines[1]);

        int lc, rc;
        int[] table = new int[n+2];
        for (int i = 0; i < m; i++) {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        }

        for (int i = 0; i < n; i++) {
          table[i+1] += table[i];
        }

        int cnt = 0;
        for (int i : table) {
          if(i == m) cnt++;
        }

        final int ans = cnt;
        out.println(ans);
        out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
} public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

        String[] lines = in.readLine().split(" ");
        final int n = Integer.parseInt(lines[0]);
        final int m = Integer.parseInt(lines[1]);

        int lc, rc;
        int[] table = new int[n+2];
        for (int i = 0; i < m; i++) {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        }

        for (int i = 0; i < n; i++) {
          table[i+1] += table[i];
        }

        int cnt = 0;
        for (int i : table) {
          if(i == m) cnt++;
        }

        final int ans = cnt;
        out.println(ans);
        out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
} Main
import java.io.*;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

        String[] lines = in.readLine().split(" ");
        final int n = Integer.parseInt(lines[0]);
        final int m = Integer.parseInt(lines[1]);

        int lc, rc;
        int[] table = new int[n+2];
        for (int i = 0; i < m; i++) {
          lines = in.readLine().split(" ");
          lc = Integer.parseInt(lines[0]);
          rc = Integer.parseInt(lines[1]);
          table[lc]   += 1;
          table[rc+1] -= 1;
        }

        for (int i = 0; i < n; i++) {
          table[i+1] += table[i];
        }

        int cnt = 0;
        for (int i : table) {
          if(i == m) cnt++;
        }

        final int ans = cnt;
        out.println(ans);
        out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}