import java.io.*;
import java.util.*;

class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = test_cases; i >= 1; i--) {
            s.solve(1, in, out);
        }
        out.close();
    }

    static class Solver {

        public void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            int ans = 0;
            for (int i = a; i <= b; i++) if (i >= c && i <= d) ans++;
            if (ans > 0) ans--;
            out.print(ans);
        }

        private boolean check(char[] s) {
            for (int i = 0; i < s.length / 2; i++) if (s[i] != s[s.length - i - 1]) return false;
            return true;
        }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
} import java.io.*; io.* java import java.util.*; util.* java class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = test_cases; i >= 1; i--) {
            s.solve(1, in, out);
        }
        out.close();
    }

    static class Solver {

        public void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            int ans = 0;
            for (int i = a; i <= b; i++) if (i >= c && i <= d) ans++;
            if (ans > 0) ans--;
            out.print(ans);
        }

        private boolean check(char[] s) {
            for (int i = 0; i < s.length / 2; i++) if (s[i] != s[s.length - i - 1]) return false;
            return true;
        }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
} Main public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = test_cases; i >= 1; i--) {
            s.solve(1, in, out);
        }
        out.close();
    } main {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = test_cases; i >= 1; i--) {
            s.solve(1, in, out);
        }
        out.close();
    } InputReader in = new InputReader(); in new InputReader() PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int test_cases = 1; test_cases 1 Solver s = new Solver(); s new Solver() for (int i = test_cases; i >= 1; i--) {
            s.solve(1, in, out);
        } int i = test_cases; int i = test_cases; i test_cases i >= 1 i 1 i-- i-- i {
            s.solve(1, in, out);
        } {
            s.solve(1, in, out);
        } s.solve(1, in, out) s.solve s 1 in out out.close() out.close out String[] args args static class Solver {

        public void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            int ans = 0;
            for (int i = a; i <= b; i++) if (i >= c && i <= d) ans++;
            if (ans > 0) ans--;
            out.print(ans);
        }

        private boolean check(char[] s) {
            for (int i = 0; i < s.length / 2; i++) if (s[i] != s[s.length - i - 1]) return false;
            return true;
        }
    } Solver public void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            int ans = 0;
            for (int i = a; i <= b; i++) if (i >= c && i <= d) ans++;
            if (ans > 0) ans--;
            out.print(ans);
        } solve {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            int ans = 0;
            for (int i = a; i <= b; i++) if (i >= c && i <= d) ans++;
            if (ans > 0) ans--;
            out.print(ans);
        } int a = in.nextInt(); a in.nextInt() in.nextInt in int b = in.nextInt(); b in.nextInt() in.nextInt in int c = in.nextInt(); c in.nextInt() in.nextInt in int d = in.nextInt(); d in.nextInt() in.nextInt in int ans = 0; ans 0 for (int i = a; i <= b; i++) if (i >= c && i <= d) ans++; int i = a; int i = a; i a i <= b i b i++ i++ i if (i >= c && i <= d) ans++; if (i >= c && i <= d) ans++; i >= c && i <= d i >= c i c i <= d i d ans++ ans if (ans > 0) ans--; ans > 0 ans 0 ans-- ans out.print(ans) out.print out ans int test_number test_number InputReader in in PrintWriter out out private boolean check(char[] s) {
            for (int i = 0; i < s.length / 2; i++) if (s[i] != s[s.length - i - 1]) return false;
            return true;
        } check {
            for (int i = 0; i < s.length / 2; i++) if (s[i] != s[s.length - i - 1]) return false;
            return true;
        } for (int i = 0; i < s.length / 2; i++) if (s[i] != s[s.length - i - 1]) return false; int i = 0; int i = 0; i 0 i < s.length / 2 i s.length / 2 s.length s s.length 2 i++ i++ i if (s[i] != s[s.length - i - 1]) return false; if (s[i] != s[s.length - i - 1]) return false; s[i] != s[s.length - i - 1] s[i] s i s[s.length - i - 1] s s.length - i - 1 s.length - i - 1 s.length s s.length i 1 return false; false return true; true char[] s s static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    } InputReader BufferedReader br; br StringTokenizer st; st public InputReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        } InputReader {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        } br = new BufferedReader(new
                    InputStreamReader(System.in)) br new BufferedReader(new
                    InputStreamReader(System.in)) String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        } while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            } st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            } try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                } catch (IOException  e)
                {
                    e.printStackTrace();
                } IOException  e {
                    e.printStackTrace();
                } e.printStackTrace() e.printStackTrace e {
                    st = new StringTokenizer(br.readLine());
                } st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st int nextInt()
        {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next long nextLong()
        {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next double nextDouble()
        {
            return Double.parseDouble(next());
        } nextDouble {
            return Double.parseDouble(next());
        } return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        } nextLine {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        } String str = ""; str "" try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            } catch (IOException e)
            {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                str = br.readLine();
            } str = br.readLine() str br.readLine() br.readLine br return str; str
import java.io.*;
import java.util.*;

class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = test_cases; i >= 1; i--) {
            s.solve(1, in, out);
        }
        out.close();
    }

    static class Solver {

        public void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            int ans = 0;
            for (int i = a; i <= b; i++) if (i >= c && i <= d) ans++;
            if (ans > 0) ans--;
            out.print(ans);
        }

        private boolean check(char[] s) {
            for (int i = 0; i < s.length / 2; i++) if (s[i] != s[s.length - i - 1]) return false;
            return true;
        }
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}