import java.util.*; import java.io.*; import java.math.*; public class No208 { public static int ans = Integer.MAX_VALUE; public static int x, y, x2, y2; public static void main(String[] args) { Scanner sc = new Scanner(System.in); x = sc.nextInt(); y = sc.nextInt(); x2 = sc.nextInt(); y2 = sc.nextInt(); sou(0, 0, 0); System.out.println(ans); } public static void sou(int cx, int cy, int cnt) { if(cx > x || cy > y) return; if(cx == x && cy == y) ans = Math.min(cnt, ans); if(cx+1 != x2 || cy+1 != y2) sou(cx+1, cy+1, cnt+1); if(cx != x2 || cy+1 != y2) sou(cx, cy+1, cnt+1); if(cx+1 != x2 || cy != y2) sou(cx+1, cy, cnt+1); } }