import java.util.*;
public class Jakkara {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
long a = input.nextLong();
long b = input.nextLong();
long c = input.nextLong();
long d = input.nextLong();
// Tutkitaan neljä tapausta, valitaan pienin energia.
// long pienin = Long.parseLong("10000000000");
long pienin = Math.abs(b-a) + Math.abs(c-a) + Math.abs(d-a);
long energy2 = Math.abs(a-b) + Math.abs(c-b) + Math.abs(d-b);
if (energy2 < pienin) pienin = energy2;
long energy3 = Math.abs(a-c) + Math.abs(b-c) + Math.abs(d-c);
if (energy3 < pienin) pienin = energy3;
long energy4 = Math.abs(a-d) + Math.abs(b-d) + Math.abs(c-d);
if (energy4 < pienin) pienin = energy4;
System.out.println(pienin);
}
}