import java.io.*;
import java.util.*;

public class pobeda_vd_wa1 {
	
	public long solveFast(long a, long b, long c, long d) {
		return (long)(Math.sqrt(Math.min(a,b) + Math.min(c,d)));
	}
	


	final String fileName = "pobeda_vd_".split("_")[0];

	public void run() throws IOException {
		br = new BufferedReader(new FileReader(fileName + ".in"));
		out = new PrintWriter(fileName + ".out");
		out.println(solveFast(nextLong(), nextLong(), nextLong(), nextLong()));
		out.close();
		br.close();
	}                                                       

	public static void main(String[] args) throws IOException {
		new pobeda_vd_wa1().run();
	}

	BufferedReader br;
	StringTokenizer str;
	PrintWriter out;

	String next() throws IOException {
		while (str == null || !str.hasMoreTokens()) {
			str = new StringTokenizer(br.readLine());
		}
		return str.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

}