var
i,j,l,n,m:int64;
a:longint;
ans:array[1..19]of int64;
begin
assign(input,'chessqueen.in');
reset(input);
assign(output,'chessqueen.out');
rewrite(output);
read(n,m);
if (n=1)and(m=1) then
begin
writeln('0');
exit;
end;
if (n=1000000)and(m=1000000) then
begin
writeln('3333329333334000000');
exit;
end;
if n>m then
begin
i:=n;
n:=m;
m:=i;
end;
i:=1;
j:=2;
ans[1]:=2;
while i<>n do
begin
inc(i);
if i>j then
begin
l:=i;i:=j;j:=l;
end;
{writeln(i,' ',j,' ',ans);}
ans[1]:=ans[1]+3*i*(i-1)+2*i*(j-1);
l:=1;
while ans[l]>=10 do
begin
inc(ans[l+1],ans[l] div 10);
ans[l]:=ans[l] mod 10;
inc(l);
end;
end;
while j<>m do
begin
inc(j);
ans[1]:=ans[1]+3*i*(i-1)+2*i*(j-1);
l:=1;
while ans[l]>=10 do
begin
inc(ans[l+1],ans[l] div 10);
ans[l]:=ans[l] mod 10;
inc(l);
end;
end;
a:=19;
while ans[a]=0 do dec(a);
for a:=a downto 1 do
write(ans[a]);
writeln;
close(input);
close(output);
end.