import java.util.Scanner;
public class Jalka {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int a, b, c, d = 0;
a = input.nextInt();
b = input.nextInt();
c = input.nextInt();
d = input.nextInt();
int keski = (a + b + c + d) / 4;
int energia = 0;
energia += energiaa(a, keski);
energia += energiaa(b, keski);
energia += energiaa(c, keski);
energia += energiaa(d, keski);
System.out.println(energia);
}
public static int energiaa(int jalka, int keski) {
if (jalka > keski) {
return jalka - keski;
} else {
return jalka + keski;
}
}
}