var
a,b,c,d,maxo,maxx,counto,countx:longint;
function max(x,y:longint):longint;
begin
if x>=y then max:=x else y:=x;
end;
begin
assign(input,'pc.in');reset(input);
assign(output,'pc.out');rewrite(output);
while not eof do
begin
read(counto,countx,maxo,maxx);
if maxo>0 then begin a:=counto div maxo;c:=counto mod maxo;end;
if maxx>0 then begin b:=countx div maxx;d:=countx mod maxx;end;
if (counto>0)and(countx>0)and(maxo>0)and(maxx>0)then
begin
if a=b then
write(a*counto+b*countx+max(c,d));
if (a+1=b)or(b+1=a) then
write(countx+counto);
if a>b+1 then
if maxx=1 then write(b*2+1)
else if countx>0 then write((countx+1)*(maxo+1)-1);
if b>a+1 then
if maxo=1 then write(a*2+1)
else if counto>0 then write((counto+1)*(maxx+1)-1);
writeln;
end;
if (counto=0)and(countx=0)then write(0);
if (counto>0)and(countx=0)then write(maxo);
if (counto=0)and(countx>0)then write(maxx);
if (maxo>0)and(maxx=0)then writeln(counto);
if (maxo=0)and(maxx>0)then writeln(countx);
if (maxo=0)and(maxx=0)then writeln(0);
end;
close(input);
close(output);
end.