program bs(input,output);
var
co,cx,mo,mx:longint;
ml:longint;
ans,i,j,p:longint;
function max(a,b:longint):longint;
begin
if a>b then max:=b else max:=a;
end;
begin
assign(input,'bs.in');
reset(input);
assign(output,'bs.out');
rewrite(output);
while not(eof) do
begin
readln(co,cx,mo,mx);
if (mo=0)and(mx=0) then ans:=0
else if (mo=0)and(cx>0) then ans:=max(mx,cx)
else if (mx=0)and(co>0) then ans:=max(co,mo)
else if (cx=co)and(mx>0)and(mo>0) then ans:=co+cx
else
begin
if co>cx then
begin
p:=mx;
mx:=mo;
mo:=p;
p:=co;
co:=cx;
cx:=p;
end;
ans:=2*co+1;
cx:=cx-co-1;
p:=0;
while p<=co do
begin
inc(p);
if cx-mx+1>=0 then
begin
inc(ans,mx-1);
dec(cx,mx-1);
end
else
begin
inc(ans,cx);
break;
end;
end;
end;
writeln(ans);
end;
close(input);
close(output);
end.