var a,b,c,d:integer; function max (const x,y:integer):integer; begin if (x>y) then max:=x else max:=y; end; function min (const x,y:integer):integer; begin if (x<y) then min:=x else min:=y; end; begin readln (a,b,c,d); writeln (max(min(a,b),min(c,d))); end.
function max (const x,y:integer):integer;
begin
if (x>y) then max:=x else max:=y;
end;
function min (const x,y:integer):integer;
begin
if (x<y) then min:=x else min:=y;
end;
begin
readln (a,b,c,d);
writeln (max(min(a,b),min(c,d)));
end.