program solitario;
var N,M,app, soluzione:longint;
griglia:array[0..10,0..10] of longint;
function gioca(r, c: longint): boolean;
begin
(*tris orizzontale*)
if (c-2>=0) and (griglia[r][c-2]=1) and (griglia[r][c-1]=1) then gioca:=false
(*tris verticale*)
else if (r-2>=0) and (griglia[r-2][c]=1) and (griglia[r-1][c]=1) then gioca:=false
(* Tris diagonale in alto a sx*)
else if (r-2>=0 ) and (c-2>=0) and (griglia[r-2][c-2]=1) and (griglia[r-1][c-1]=1) then gioca:=false
(* Tris diagonale in alto a dx*)
else if (r-2>=0) and (c+2<=M) and (griglia[r-2][c+2]=1) and (griglia[r-1][c+1]=1) then gioca:=false
else gioca := true;
end;
Procedure riempi (riga:longint; colonna:longint; tot:longint);
begin
if colonna=M then begin riga:=riga+1; colonna:=0; end;
if riga=N then begin if tot>soluzione then soluzione:=tot; exit;end;
(*Se posso, metto la X*)
if gioca (riga,colonna)=true then
begin
griglia[riga][colonna]:=1;
Riempi(riga,colonna+1, tot+1);
(* Reset della griglia[riga][col]*)
griglia[riga][colonna]:=0;
end;
if (tot+((2 div 3)* (M*N- (riga*M + colonna +1)))+16)<soluzione then exit ;
(* Non metto la X*)
Riempi(riga,colonna+1, tot);
end;
begin
readln(N,M);
soluzione:=0; riempi(0,0,0);
writeln(soluzione);
end.
cHJvZ3JhbSBzb2xpdGFyaW87CnZhciBOLE0sYXBwLCBzb2x1emlvbmU6bG9uZ2ludDsKICAgIGdyaWdsaWE6YXJyYXlbMC4uMTAsMC4uMTBdIG9mIGxvbmdpbnQ7CiAgICAKZnVuY3Rpb24gZ2lvY2EociwgYzogbG9uZ2ludCk6IGJvb2xlYW47CmJlZ2luCiAgICAgICgqdHJpcyBvcml6em9udGFsZSopCiAgIGlmIChjLTI+PTApIGFuZCAoZ3JpZ2xpYVtyXVtjLTJdPTEpIGFuZCAoZ3JpZ2xpYVtyXVtjLTFdPTEpIHRoZW4gZ2lvY2E6PWZhbHNlCiAgICAgICgqdHJpcyB2ZXJ0aWNhbGU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AgICAgICBSaWVtcGkocmlnYSxjb2xvbm5hKzEsIHRvdCsxKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKCogUmVzZXQgZGVsbGEgZ3JpZ2xpYVtyaWdhXVtjb2xdKikKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdyaWdsaWFbcmlnYV1bY29sb25uYV06PTA7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuZDsKICAgICAgaWYgKHRvdCsoKDIgZGl2IDMpKiAoTSpOLSAocmlnYSpNICsgY29sb25uYSArMSkpKSsxNik8c29sdXppb25lICB0aGVuIGV4aXQgOyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICgqIE5vbiBtZXR0byBsYSBYKikKICAgIFJpZW1waShyaWdhLGNvbG9ubmErMSwgdG90KTsgCiAgICAKZW5kOyAgICAgICAgICAgICAgICAgICAKYmVnaW4KCXJlYWRsbihOLE0pOwogICAJc29sdXppb25lOj0wOyByaWVtcGkoMCwwLDApOyAKICAgIHdyaXRlbG4oc29sdXppb25lKTsJCmVuZC4=