Uses Math;
{$N+}
var a, b, c, d: int64;
	s, sq : longint;

begin
  Assign(input, 'pobeda.in');
  Assign(output, 'pobeda.out');
  Reset(input);
  Rewrite(output);
  read(a, b, c, d);
  a := Min(a, b) + Min(c, d); 
  s := Max(1, round(sqrt(1.0 * a)) - 100);
  sq := s * s;
  while (sq <= a) do
  begin
    sq := sq + s + s + 1;
    inc(s);
  end;
  writeln(s - 1);
end.