var x,y,l,r:qword;
function min(x,y:qword):qword;
begin
if x>y then exit(y) else exit(x);
end;
procedure init;
begin
end;
function deal:qword;
begin
if min(x,l)=0 then exit(min(y,r));
if min(y,r)=0 then exit(min(x,l));
if x>l*(y+1) then exit(y+(y+1)*l);
if y>r*(x+1) then exit(x+(x+1)*r);
exit(x+y);
end;
procedure work;
begin
while not eof do
begin
readln(x,y,l,r);
writeln(deal);
end;
end;
begin
assign(input,'bs.in');reset(input);
assign(output,'bs.out');rewrite(output);
init;
work;
close(input);close(output);
end.