program bs(input,output);
var
co,cx,mo,mx:longint;
ml:longint;
ans,i,j,p:longint;
f:array[1..2000000]of longint;
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) then ans:=mx
else if (mx=0) then ans:=mo
else if (cx=co)and(mx>0)and(mo>0) then ans:=co+cx
else
begin
ml:=mo+mx;
if co>cx then
begin
p:=mx;
mx:=mo;
mo:=p;
p:=co;
co:=cx;
cx:=p;
end;
for i:=1 to co do
begin
f[i*2]:=1;
f[i*2-1]:=1;
end;
f[co*2+1]:=1;
cx:=cx-co-1;
for i:=1 to (co+1) do
begin
if cx>mx then
begin
f[i*2-1]:=mx;
cx:=cx-mx+1;
end
else
begin
f[i*2-1]:=cx+1;
break;
end;
end;
ans:=0;
for i:=1 to 2*co+1 do
ans:=ans+f[i];
for i:=1 to 2*co+1 do f[i]:=0;
end;
writeln(ans);
end;
close(input);
close(output);
end.