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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            int d = Integer.parseInt(str[3]);
            int num[] = new int[100];
            for (int i = a; i < b; i++) {
                num[i]++;
            }
            for (int i = c; i < d; i++) {
                num[i]++;
            }
            int count = 0;
            for (int i = 0; i < 100; i++) {
                if (num[i] > 1) {
                    count++;
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            int d = Integer.parseInt(str[3]);
            int num[] = new int[100];
            for (int i = a; i < b; i++) {
                num[i]++;
            }
            for (int i = c; i < d; i++) {
                num[i]++;
            }
            int count = 0;
            for (int i = 0; i < 100; i++) {
                if (num[i] > 1) {
                    count++;
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
} Main public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            int d = Integer.parseInt(str[3]);
            int num[] = new int[100];
            for (int i = a; i < b; i++) {
                num[i]++;
            }
            for (int i = c; i < d; i++) {
                num[i]++;
            }
            int count = 0;
            for (int i = 0; i < 100; i++) {
                if (num[i] > 1) {
                    count++;
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
           }
    } main {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            int d = Integer.parseInt(str[3]);
            int num[] = new int[100];
            for (int i = a; i < b; i++) {
                num[i]++;
            }
            for (int i = c; i < d; i++) {
                num[i]++;
            }
            int count = 0;
            for (int i = 0; i < 100; i++) {
                if (num[i] > 1) {
                    count++;
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
           }
    } try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            int d = Integer.parseInt(str[3]);
            int num[] = new int[100];
            for (int i = a; i < b; i++) {
                num[i]++;
            }
            for (int i = c; i < d; i++) {
                num[i]++;
            }
            int count = 0;
            for (int i = 0; i < 100; i++) {
                if (num[i] > 1) {
                    count++;
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
           } catch (IOException e) {
            e.printStackTrace();
           } IOException e {
            e.printStackTrace();
           } e.printStackTrace() e.printStackTrace e {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            int d = Integer.parseInt(str[3]);
            int num[] = new int[100];
            for (int i = a; i < b; i++) {
                num[i]++;
            }
            for (int i = c; i < d; i++) {
                num[i]++;
            }
            int count = 0;
            for (int i = 0; i < 100; i++) {
                if (num[i] > 1) {
                    count++;
                }
            }
            System.out.println(count);
        } InputStreamReader isr = new InputStreamReader(System.in); isr new InputStreamReader(System.in) BufferedReader br = new BufferedReader(isr); br new BufferedReader(isr) String str[] = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int a = Integer.parseInt(str[0]); a Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int b = Integer.parseInt(str[1]); b Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 int c = Integer.parseInt(str[2]); c Integer.parseInt(str[2]) Integer.parseInt Integer str[2] str 2 int d = Integer.parseInt(str[3]); d Integer.parseInt(str[3]) Integer.parseInt Integer str[3] str 3 int num[] = new int[100]; num new int[100] 100 for (int i = a; i < b; i++) {
                num[i]++;
            } int i = a; int i = a; i a i < b i b i++ i++ i {
                num[i]++;
            } {
                num[i]++;
            } num[i]++ num[i] num i for (int i = c; i < d; i++) {
                num[i]++;
            } int i = c; int i = c; i c i < d i d i++ i++ i {
                num[i]++;
            } {
                num[i]++;
            } num[i]++ num[i] num i int count = 0; count 0 for (int i = 0; i < 100; i++) {
                if (num[i] > 1) {
                    count++;
                }
            } int i = 0; int i = 0; i 0 i < 100 i 100 i++ i++ i {
                if (num[i] > 1) {
                    count++;
                }
            } {
                if (num[i] > 1) {
                    count++;
                }
            } if (num[i] > 1) {
                    count++;
                } num[i] > 1 num[i] num i 1 {
                    count++;
                } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            int d = Integer.parseInt(str[3]);
            int num[] = new int[100];
            for (int i = a; i < b; i++) {
                num[i]++;
            }
            for (int i = c; i < d; i++) {
                num[i]++;
            }
            int count = 0;
            for (int i = 0; i < 100; i++) {
                if (num[i] > 1) {
                    count++;
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
} public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            int d = Integer.parseInt(str[3]);
            int num[] = new int[100];
            for (int i = a; i < b; i++) {
                num[i]++;
            }
            for (int i = c; i < d; i++) {
                num[i]++;
            }
            int count = 0;
            for (int i = 0; i < 100; i++) {
                if (num[i] > 1) {
                    count++;
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str[] = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            int d = Integer.parseInt(str[3]);
            int num[] = new int[100];
            for (int i = a; i < b; i++) {
                num[i]++;
            }
            for (int i = c; i < d; i++) {
                num[i]++;
            }
            int count = 0;
            for (int i = 0; i < 100; i++) {
                if (num[i] > 1) {
                    count++;
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
}
