import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int alice_start = Integer.parseInt(sc.next());
        int alice_end = Integer.parseInt(sc.next());
        int bob_start = Integer.parseInt(sc.next());
        int bob_end = Integer.parseInt(sc.next());
        int[] alice = new int[100];
        int[] bob = new int[100];
        for (int i = 0; i < 100; i++) {
            if (i >= alice_start && i < alice_end) {
                alice[i] = 1;
            }
            if (i >= bob_start && i < bob_end) {
                bob[i] = 1;
            }
        }
        int cnt = 0;
        for (int i = 0; i < 100; i++) {
            if (alice[i] == 1 && bob[i] == 1) cnt++;
        }
        System.out.println(cnt);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int alice_start = Integer.parseInt(sc.next());
        int alice_end = Integer.parseInt(sc.next());
        int bob_start = Integer.parseInt(sc.next());
        int bob_end = Integer.parseInt(sc.next());
        int[] alice = new int[100];
        int[] bob = new int[100];
        for (int i = 0; i < 100; i++) {
            if (i >= alice_start && i < alice_end) {
                alice[i] = 1;
            }
            if (i >= bob_start && i < bob_end) {
                bob[i] = 1;
            }
        }
        int cnt = 0;
        for (int i = 0; i < 100; i++) {
            if (alice[i] == 1 && bob[i] == 1) cnt++;
        }
        System.out.println(cnt);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int alice_start = Integer.parseInt(sc.next());
        int alice_end = Integer.parseInt(sc.next());
        int bob_start = Integer.parseInt(sc.next());
        int bob_end = Integer.parseInt(sc.next());
        int[] alice = new int[100];
        int[] bob = new int[100];
        for (int i = 0; i < 100; i++) {
            if (i >= alice_start && i < alice_end) {
                alice[i] = 1;
            }
            if (i >= bob_start && i < bob_end) {
                bob[i] = 1;
            }
        }
        int cnt = 0;
        for (int i = 0; i < 100; i++) {
            if (alice[i] == 1 && bob[i] == 1) cnt++;
        }
        System.out.println(cnt);
    } main {
        Scanner sc = new Scanner(System.in);
        int alice_start = Integer.parseInt(sc.next());
        int alice_end = Integer.parseInt(sc.next());
        int bob_start = Integer.parseInt(sc.next());
        int bob_end = Integer.parseInt(sc.next());
        int[] alice = new int[100];
        int[] bob = new int[100];
        for (int i = 0; i < 100; i++) {
            if (i >= alice_start && i < alice_end) {
                alice[i] = 1;
            }
            if (i >= bob_start && i < bob_end) {
                bob[i] = 1;
            }
        }
        int cnt = 0;
        for (int i = 0; i < 100; i++) {
            if (alice[i] == 1 && bob[i] == 1) cnt++;
        }
        System.out.println(cnt);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int alice_start = Integer.parseInt(sc.next()); alice_start Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int alice_end = Integer.parseInt(sc.next()); alice_end Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int bob_start = Integer.parseInt(sc.next()); bob_start Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int bob_end = Integer.parseInt(sc.next()); bob_end Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] alice = new int[100]; alice new int[100] 100 int[] bob = new int[100]; bob new int[100] 100 for (int i = 0; i < 100; i++) {
            if (i >= alice_start && i < alice_end) {
                alice[i] = 1;
            }
            if (i >= bob_start && i < bob_end) {
                bob[i] = 1;
            }
        } int i = 0; int i = 0; i 0 i < 100 i 100 i++ i++ i {
            if (i >= alice_start && i < alice_end) {
                alice[i] = 1;
            }
            if (i >= bob_start && i < bob_end) {
                bob[i] = 1;
            }
        } {
            if (i >= alice_start && i < alice_end) {
                alice[i] = 1;
            }
            if (i >= bob_start && i < bob_end) {
                bob[i] = 1;
            }
        } if (i >= alice_start && i < alice_end) {
                alice[i] = 1;
            } i >= alice_start && i < alice_end i >= alice_start i alice_start i < alice_end i alice_end {
                alice[i] = 1;
            } alice[i] = 1 alice[i] alice i 1 if (i >= bob_start && i < bob_end) {
                bob[i] = 1;
            } i >= bob_start && i < bob_end i >= bob_start i bob_start i < bob_end i bob_end {
                bob[i] = 1;
            } bob[i] = 1 bob[i] bob i 1 int cnt = 0; cnt 0 for (int i = 0; i < 100; i++) {
            if (alice[i] == 1 && bob[i] == 1) cnt++;
        } int i = 0; int i = 0; i 0 i < 100 i 100 i++ i++ i {
            if (alice[i] == 1 && bob[i] == 1) cnt++;
        } {
            if (alice[i] == 1 && bob[i] == 1) cnt++;
        } if (alice[i] == 1 && bob[i] == 1) cnt++; alice[i] == 1 && bob[i] == 1 alice[i] == 1 alice[i] alice i 1 bob[i] == 1 bob[i] bob i 1 cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int alice_start = Integer.parseInt(sc.next());
        int alice_end = Integer.parseInt(sc.next());
        int bob_start = Integer.parseInt(sc.next());
        int bob_end = Integer.parseInt(sc.next());
        int[] alice = new int[100];
        int[] bob = new int[100];
        for (int i = 0; i < 100; i++) {
            if (i >= alice_start && i < alice_end) {
                alice[i] = 1;
            }
            if (i >= bob_start && i < bob_end) {
                bob[i] = 1;
            }
        }
        int cnt = 0;
        for (int i = 0; i < 100; i++) {
            if (alice[i] == 1 && bob[i] == 1) cnt++;
        }
        System.out.println(cnt);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int alice_start = Integer.parseInt(sc.next());
        int alice_end = Integer.parseInt(sc.next());
        int bob_start = Integer.parseInt(sc.next());
        int bob_end = Integer.parseInt(sc.next());
        int[] alice = new int[100];
        int[] bob = new int[100];
        for (int i = 0; i < 100; i++) {
            if (i >= alice_start && i < alice_end) {
                alice[i] = 1;
            }
            if (i >= bob_start && i < bob_end) {
                bob[i] = 1;
            }
        }
        int cnt = 0;
        for (int i = 0; i < 100; i++) {
            if (alice[i] == 1 && bob[i] == 1) cnt++;
        }
        System.out.println(cnt);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int alice_start = Integer.parseInt(sc.next());
        int alice_end = Integer.parseInt(sc.next());
        int bob_start = Integer.parseInt(sc.next());
        int bob_end = Integer.parseInt(sc.next());
        int[] alice = new int[100];
        int[] bob = new int[100];
        for (int i = 0; i < 100; i++) {
            if (i >= alice_start && i < alice_end) {
                alice[i] = 1;
            }
            if (i >= bob_start && i < bob_end) {
                bob[i] = 1;
            }
        }
        int cnt = 0;
        for (int i = 0; i < 100; i++) {
            if (alice[i] == 1 && bob[i] == 1) cnt++;
        }
        System.out.println(cnt);
    }
}
