var m,n,i,c: integer; begin read (n,m); i:=0; if n<m then c:=n else c:=m; if (c mod 2)=1 then begin n:=n-2*(c div 2); i:=i+4*(c div 2); m:=m-2*(c div 2); end else begin c:=c-1; n:=n-2*(c div 2); i:=i+4*(c div 2); m:=m-2*(c div 2); end; if n=1 then else if m=1 then inc (i) else if n=2 then i:=i+2 else i:=i+3; writeln (i); end.