public class No_208 { static boolean straight(int x, int y) { if (x == 0 || y == 0 || Math.abs(x) == Math.abs(y)) { return true; } else { return false; } } static String direction(int x, int y) { if (x == 0) { if (y > 0) return "N"; else return "S"; } else if (y == 0) { if (x > 0) return "E"; else return "W"; } else if (x == y) { if (x > 0) return "NE"; else return "SW"; } else { if (x > y) return "SE"; else return "NW"; } } static boolean inTheWay(String dir, int X, int Y, int fuX, int fuY) { switch (dir) { case "N": case "NE": if (Y > fuY) return true; else return false; case "E": case "SE": if (X > fuX) return true; else return false; case "S": case "SW": if (Y < fuY) return true; else return false; case "W": case "NW": if (X < fuX) return true; else return false; } return false; } public static void main(String[] args) { java.util.Scanner sc = new java.util.Scanner(System.in); int X, Y, fuX, fuY; X = sc.nextInt(); Y = sc.nextInt(); fuX = sc.nextInt(); fuY = sc.nextInt(); int step = Math.max(X, Y); if (straight(X, Y) && straight(fuX, fuY)) { String dir = direction(X, Y); if (dir.equals(direction(fuX, fuY))) { if (inTheWay(dir, X, Y, fuX, fuY)) { step += 1; } } } System.out.println(step); sc.close(); } }