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

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        if (C < A) {
            int t1 = A;
            int t2 = B;
            A = C;
            B = D;
            C = t1;
            D = t2;
        }
        if (B <= C) {
            System.out.println(0);
            return;
        }
        List<Integer> data = new ArrayList<Integer>();
        data.add(A);
        data.add(B);
        data.add(C);
        data.add(D);
        data.sort(Comparator.naturalOrder());
        int answer = data.get(2)-data.get(1);
        System.out.println(answer);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        if (C < A) {
            int t1 = A;
            int t2 = B;
            A = C;
            B = D;
            C = t1;
            D = t2;
        }
        if (B <= C) {
            System.out.println(0);
            return;
        }
        List<Integer> data = new ArrayList<Integer>();
        data.add(A);
        data.add(B);
        data.add(C);
        data.add(D);
        data.sort(Comparator.naturalOrder());
        int answer = data.get(2)-data.get(1);
        System.out.println(answer);
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        if (C < A) {
            int t1 = A;
            int t2 = B;
            A = C;
            B = D;
            C = t1;
            D = t2;
        }
        if (B <= C) {
            System.out.println(0);
            return;
        }
        List<Integer> data = new ArrayList<Integer>();
        data.add(A);
        data.add(B);
        data.add(C);
        data.add(D);
        data.sort(Comparator.naturalOrder());
        int answer = data.get(2)-data.get(1);
        System.out.println(answer);
    } main {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        if (C < A) {
            int t1 = A;
            int t2 = B;
            A = C;
            B = D;
            C = t1;
            D = t2;
        }
        if (B <= C) {
            System.out.println(0);
            return;
        }
        List<Integer> data = new ArrayList<Integer>();
        data.add(A);
        data.add(B);
        data.add(C);
        data.add(D);
        data.sort(Comparator.naturalOrder());
        int answer = data.get(2)-data.get(1);
        System.out.println(answer);
    } Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in))); scan new Scanner(new BufferedReader(new InputStreamReader(System.in))) int A = scan.nextInt(); A scan.nextInt() scan.nextInt scan int B = scan.nextInt(); B scan.nextInt() scan.nextInt scan int C = scan.nextInt(); C scan.nextInt() scan.nextInt scan int D = scan.nextInt(); D scan.nextInt() scan.nextInt scan if (C < A) {
            int t1 = A;
            int t2 = B;
            A = C;
            B = D;
            C = t1;
            D = t2;
        } C < A C A {
            int t1 = A;
            int t2 = B;
            A = C;
            B = D;
            C = t1;
            D = t2;
        } int t1 = A; t1 A int t2 = B; t2 B A = C A C B = D B D C = t1 C t1 D = t2 D t2 if (B <= C) {
            System.out.println(0);
            return;
        } B <= C B C {
            System.out.println(0);
            return;
        } System.out.println(0) System.out.println System.out System System.out 0 return; List<Integer> data = new ArrayList<Integer>(); data new ArrayList<Integer>() data.add(A) data.add data A data.add(B) data.add data B data.add(C) data.add data C data.add(D) data.add data D data.sort(Comparator.naturalOrder()) data.sort data Comparator.naturalOrder() Comparator.naturalOrder Comparator int answer = data.get(2)-data.get(1); answer data.get(2)-data.get(1) data.get(2) data.get data 2 data.get(1) data.get data 1 System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        if (C < A) {
            int t1 = A;
            int t2 = B;
            A = C;
            B = D;
            C = t1;
            D = t2;
        }
        if (B <= C) {
            System.out.println(0);
            return;
        }
        List<Integer> data = new ArrayList<Integer>();
        data.add(A);
        data.add(B);
        data.add(C);
        data.add(D);
        data.sort(Comparator.naturalOrder());
        int answer = data.get(2)-data.get(1);
        System.out.println(answer);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        if (C < A) {
            int t1 = A;
            int t2 = B;
            A = C;
            B = D;
            C = t1;
            D = t2;
        }
        if (B <= C) {
            System.out.println(0);
            return;
        }
        List<Integer> data = new ArrayList<Integer>();
        data.add(A);
        data.add(B);
        data.add(C);
        data.add(D);
        data.sort(Comparator.naturalOrder());
        int answer = data.get(2)-data.get(1);
        System.out.println(answer);
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        if (C < A) {
            int t1 = A;
            int t2 = B;
            A = C;
            B = D;
            C = t1;
            D = t2;
        }
        if (B <= C) {
            System.out.println(0);
            return;
        }
        List<Integer> data = new ArrayList<Integer>();
        data.add(A);
        data.add(B);
        data.add(C);
        data.add(D);
        data.sort(Comparator.naturalOrder());
        int answer = data.get(2)-data.get(1);
        System.out.println(answer);
    }
}
