import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static int solve(int a, int b, int c, int d) {
        int total = 0;
        for(int i = a; i < b; i++){
            for(int x = c; x < d; x++){
                if(i == x){
                    total++;
                }
            }
        }
        return total;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        System.out.println(solve(a,b,c,d));
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util public class Main {

    public static int solve(int a, int b, int c, int d) {
        int total = 0;
        for(int i = a; i < b; i++){
            for(int x = c; x < d; x++){
                if(i == x){
                    total++;
                }
            }
        }
        return total;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        System.out.println(solve(a,b,c,d));
    }
} Main public static int solve(int a, int b, int c, int d) {
        int total = 0;
        for(int i = a; i < b; i++){
            for(int x = c; x < d; x++){
                if(i == x){
                    total++;
                }
            }
        }
        return total;
    } solve {
        int total = 0;
        for(int i = a; i < b; i++){
            for(int x = c; x < d; x++){
                if(i == x){
                    total++;
                }
            }
        }
        return total;
    } int total = 0; total 0 for(int i = a; i < b; i++){
            for(int x = c; x < d; x++){
                if(i == x){
                    total++;
                }
            }
        } int i = a; int i = a; i a i < b i b i++ i++ i {
            for(int x = c; x < d; x++){
                if(i == x){
                    total++;
                }
            }
        } {
            for(int x = c; x < d; x++){
                if(i == x){
                    total++;
                }
            }
        } for(int x = c; x < d; x++){
                if(i == x){
                    total++;
                }
            } int x = c; int x = c; x c x < d x d x++ x++ x {
                if(i == x){
                    total++;
                }
            } {
                if(i == x){
                    total++;
                }
            } if(i == x){
                    total++;
                } i == x i x {
                    total++;
                } total++ total return total; total int a a int b b int c c int d d public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        System.out.println(solve(a,b,c,d));
    } main {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        System.out.println(solve(a,b,c,d));
    } Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); in new Scanner(new BufferedReader(new InputStreamReader(System.in))) 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 System.out.println(solve(a,b,c,d)) System.out.println System.out System System.out solve(a,b,c,d) solve a b c d String[] args args public class Main {

    public static int solve(int a, int b, int c, int d) {
        int total = 0;
        for(int i = a; i < b; i++){
            for(int x = c; x < d; x++){
                if(i == x){
                    total++;
                }
            }
        }
        return total;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        System.out.println(solve(a,b,c,d));
    }
} public class Main {

    public static int solve(int a, int b, int c, int d) {
        int total = 0;
        for(int i = a; i < b; i++){
            for(int x = c; x < d; x++){
                if(i == x){
                    total++;
                }
            }
        }
        return total;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        System.out.println(solve(a,b,c,d));
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static int solve(int a, int b, int c, int d) {
        int total = 0;
        for(int i = a; i < b; i++){
            for(int x = c; x < d; x++){
                if(i == x){
                    total++;
                }
            }
        }
        return total;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        System.out.println(solve(a,b,c,d));
    }
}