본문으로 바로가기
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		int w = sc.nextInt();
		int h = sc.nextInt();
		
		int w_min; // 가로 거리의 최소값
		int h_min; // 세로 거리의 최소값
		
		w_min = ((w - x) > x) ? x : w - x;
		h_min = ((h - y) > y) ? y : h - y;
		
		if (w_min > h_min)
			System.out.println(h_min);
		else
			System.out.println(w_min);
		
		sc.close();
	}
}