import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Math.*;

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        int[] a = intarr();
        int[] c = new int[111];
        for(int i=a[0];i<=a[1];i++) {
            c[i]++;
        }
        for(int i=a[2];i<=a[3];i++) {
            c[i]++;
        }
        int res = 0;
        for(int x: c) {
            if(x == 2) {
                res++;
            }
        }
        out(max(0,res-1));
    }

    private int[] intarr() throws IOException {
        return intarr(rd.readLine());
    }

    private int[] intarr(String s) {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    }

    private String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        int[] a = intarr();
        int[] c = new int[111];
        for(int i=a[0];i<=a[1];i++) {
            c[i]++;
        }
        for(int i=a[2];i<=a[3];i++) {
            c[i]++;
        }
        int res = 0;
        for(int x: c) {
            if(x == 2) {
                res++;
            }
        }
        out(max(0,res-1));
    }

    private int[] intarr() throws IOException {
        return intarr(rd.readLine());
    }

    private int[] intarr(String s) {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    }

    private String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
} Main BufferedReader rd; rd Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    } Main {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    } rd = new BufferedReader(new InputStreamReader(System.in)) rd new BufferedReader(new InputStreamReader(System.in)) compute() compute private void compute() throws IOException {
        int[] a = intarr();
        int[] c = new int[111];
        for(int i=a[0];i<=a[1];i++) {
            c[i]++;
        }
        for(int i=a[2];i<=a[3];i++) {
            c[i]++;
        }
        int res = 0;
        for(int x: c) {
            if(x == 2) {
                res++;
            }
        }
        out(max(0,res-1));
    } compute {
        int[] a = intarr();
        int[] c = new int[111];
        for(int i=a[0];i<=a[1];i++) {
            c[i]++;
        }
        for(int i=a[2];i<=a[3];i++) {
            c[i]++;
        }
        int res = 0;
        for(int x: c) {
            if(x == 2) {
                res++;
            }
        }
        out(max(0,res-1));
    } int[] a = intarr(); a intarr() intarr int[] c = new int[111]; c new int[111] 111 for(int i=a[0];i<=a[1];i++) {
            c[i]++;
        } int i=a[0]; int i=a[0]; i a[0] a 0 i<=a[1] i a[1] a 1 i++ i++ i {
            c[i]++;
        } {
            c[i]++;
        } c[i]++ c[i] c i for(int i=a[2];i<=a[3];i++) {
            c[i]++;
        } int i=a[2]; int i=a[2]; i a[2] a 2 i<=a[3] i a[3] a 3 i++ i++ i {
            c[i]++;
        } {
            c[i]++;
        } c[i]++ c[i] c i int res = 0; res 0 for(int x: c) {
            if(x == 2) {
                res++;
            }
        } int x c {
            if(x == 2) {
                res++;
            }
        } {
            if(x == 2) {
                res++;
            }
        } if(x == 2) {
                res++;
            } x == 2 x 2 {
                res++;
            } res++ res out(max(0,res-1)) out max(0,res-1) max 0 res-1 res 1 private int[] intarr() throws IOException {
        return intarr(rd.readLine());
    } intarr {
        return intarr(rd.readLine());
    } return intarr(rd.readLine()); intarr(rd.readLine()) intarr rd.readLine() rd.readLine rd private int[] intarr(String s) {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    } intarr {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    } String[] q = split(s); q split(s) split s int n = q.length; n q.length q q.length int[] a = new int[n]; a new int[n] n for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            a[i] = Integer.parseInt(q[i]);
        } {
            a[i] = Integer.parseInt(q[i]);
        } a[i] = Integer.parseInt(q[i]) a[i] a i Integer.parseInt(q[i]) Integer.parseInt Integer q[i] q i return a; a String s s private String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    } split {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    } if(s == null) {
            return new String[0];
        } s == null s null {
            return new String[0];
        } return new String[0]; new String[0] 0 int n = s.length(); n s.length() s.length s int start = -1; start -1 1 int end = 0; end 0 int sp = 0; sp 0 boolean lastWhitespace = true; lastWhitespace true for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        } {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        } char c = s.charAt(i); c s.charAt(i) s.charAt s i if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            } isWhitespace(c) isWhitespace c {
                lastWhitespace = true;
            } lastWhitespace = true lastWhitespace true {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            } if(lastWhitespace) {
                    sp++;
                } lastWhitespace {
                    sp++;
                } sp++ sp if(start == -1) {
                    start = i;
                } start == -1 start -1 1 {
                    start = i;
                } start = i start i end = i end i lastWhitespace = false lastWhitespace false if(start == -1) {
            return new String[0];
        } start == -1 start -1 1 {
            return new String[0];
        } return new String[0]; new String[0] 0 String[] res = new String[sp]; res new String[sp] sp int last = start; last start int x = 0; x 0 lastWhitespace = true lastWhitespace true for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        } int i=start; int i=start; i start i<=end i end i++ i++ i {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        } {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        } char c = s.charAt(i); c s.charAt(i) s.charAt s i boolean w = isWhitespace(c); w isWhitespace(c) isWhitespace c if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            } w && !lastWhitespace w !lastWhitespace lastWhitespace {
                res[x++] = s.substring(last,i);
            } res[x++] = s.substring(last,i) res[x++] res x++ x s.substring(last,i) s.substring s last i if(!w && lastWhitespace) {
                last = i;
            } !w && lastWhitespace !w w lastWhitespace {
                last = i;
            } last = i last i lastWhitespace = w lastWhitespace w res[x] = s.substring(last,end+1) res[x] res x s.substring(last,end+1) s.substring s last end+1 end 1 return res; res String s s private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    } isWhitespace {
        return c==' ' || c=='\t';
    } return c==' ' || c=='\t'; c==' ' || c=='\t' c==' ' c ' ' c=='\t' c '\t' char c c private static void out(Object x) {
        System.out.println(x);
    } out {
        System.out.println(x);
    } System.out.println(x) System.out.println System.out System System.out x Object x x public static void main(String[] args) throws IOException {
        new Main();
    } main {
        new Main();
    } new Main() String[] args args public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        int[] a = intarr();
        int[] c = new int[111];
        for(int i=a[0];i<=a[1];i++) {
            c[i]++;
        }
        for(int i=a[2];i<=a[3];i++) {
            c[i]++;
        }
        int res = 0;
        for(int x: c) {
            if(x == 2) {
                res++;
            }
        }
        out(max(0,res-1));
    }

    private int[] intarr() throws IOException {
        return intarr(rd.readLine());
    }

    private int[] intarr(String s) {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    }

    private String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
} public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        int[] a = intarr();
        int[] c = new int[111];
        for(int i=a[0];i<=a[1];i++) {
            c[i]++;
        }
        for(int i=a[2];i<=a[3];i++) {
            c[i]++;
        }
        int res = 0;
        for(int x: c) {
            if(x == 2) {
                res++;
            }
        }
        out(max(0,res-1));
    }

    private int[] intarr() throws IOException {
        return intarr(rd.readLine());
    }

    private int[] intarr(String s) {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    }

    private String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Math.*;

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        int[] a = intarr();
        int[] c = new int[111];
        for(int i=a[0];i<=a[1];i++) {
            c[i]++;
        }
        for(int i=a[2];i<=a[3];i++) {
            c[i]++;
        }
        int res = 0;
        for(int x: c) {
            if(x == 2) {
                res++;
            }
        }
        out(max(0,res-1));
    }

    private int[] intarr() throws IOException {
        return intarr(rd.readLine());
    }

    private int[] intarr(String s) {
        String[] q = split(s);
        int n = q.length;
        int[] a = new int[n];
        for(int i=0;i<n;i++) {
            a[i] = Integer.parseInt(q[i]);
        }
        return a;
    }

    private String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}
