import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        if((B<C && A<C) || (C<A && D<A)){
            System.out.println(0);
        }
        else{
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(A);
            list.add(B);
            list.add(C);
            list.add(D);
            Collections.sort(list);
            System.out.println(list.get(2) - list.get(1));
        }
    }
} import java.util.*; util.* java import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        if((B<C && A<C) || (C<A && D<A)){
            System.out.println(0);
        }
        else{
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(A);
            list.add(B);
            list.add(C);
            list.add(D);
            Collections.sort(list);
            System.out.println(list.get(2) - list.get(1));
        }
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        if((B<C && A<C) || (C<A && D<A)){
            System.out.println(0);
        }
        else{
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(A);
            list.add(B);
            list.add(C);
            list.add(D);
            Collections.sort(list);
            System.out.println(list.get(2) - list.get(1));
        }
    } main {
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        if((B<C && A<C) || (C<A && D<A)){
            System.out.println(0);
        }
        else{
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(A);
            list.add(B);
            list.add(C);
            list.add(D);
            Collections.sort(list);
            System.out.println(list.get(2) - list.get(1));
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int C = sc.nextInt(); C sc.nextInt() sc.nextInt sc int D = sc.nextInt(); D sc.nextInt() sc.nextInt sc if((B<C && A<C) || (C<A && D<A)){
            System.out.println(0);
        }
        else{
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(A);
            list.add(B);
            list.add(C);
            list.add(D);
            Collections.sort(list);
            System.out.println(list.get(2) - list.get(1));
        } (B<C && A<C) || (C<A && D<A) (B<C && A<C) B<C B C A<C A C (C<A && D<A) C<A C A D<A D A {
            System.out.println(0);
        } System.out.println(0) System.out.println System.out System System.out 0 {
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(A);
            list.add(B);
            list.add(C);
            list.add(D);
            Collections.sort(list);
            System.out.println(list.get(2) - list.get(1));
        } ArrayList<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() list.add(A) list.add list A list.add(B) list.add list B list.add(C) list.add list C list.add(D) list.add list D Collections.sort(list) Collections.sort Collections list System.out.println(list.get(2) - list.get(1)) System.out.println System.out System System.out list.get(2) - list.get(1) list.get(2) list.get list 2 list.get(1) list.get list 1 String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        if((B<C && A<C) || (C<A && D<A)){
            System.out.println(0);
        }
        else{
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(A);
            list.add(B);
            list.add(C);
            list.add(D);
            Collections.sort(list);
            System.out.println(list.get(2) - list.get(1));
        }
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        if((B<C && A<C) || (C<A && D<A)){
            System.out.println(0);
        }
        else{
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(A);
            list.add(B);
            list.add(C);
            list.add(D);
            Collections.sort(list);
            System.out.println(list.get(2) - list.get(1));
        }
    }
} Main
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();

        if((B<C && A<C) || (C<A && D<A)){
            System.out.println(0);
        }
        else{
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(A);
            list.add(B);
            list.add(C);
            list.add(D);
            Collections.sort(list);
            System.out.println(list.get(2) - list.get(1));
        }
    }
}