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

public class pobeda_sp implements Runnable {
	public static void main(String[] args) {
		new Thread(new pobeda_sp()).start();
	}

	@Override
	public void run() {
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	private final String FNAME = "pobeda";

	void solve() {
		long a1 = nextLong();
		long a2 = nextLong();
		long a3 = nextLong();
		long a4 = nextLong();
		long t = Math.min(a1, a2) + Math.min(a3, a4);
		double z = Math.sqrt(t);
		long ans = Math.round(Math.floor(z));
		while (ans * ans > t) {
			ans--;
		}
		out.println(ans);
	}
}