var a,b: integer;
begin
read(a);
b: =a mod 10;
a: =a div 10;
if (a mod 10 < b) and (a mod 2 = 0) then b: =a mod 10;
if b mod 2=0 then writeln(b)else writeln('-1');
end.
var a,b: integer;
begin
read(a);
b: =a mod 10;
a: =a div 10;
if (a mod 10 < b) and (a mod 2 = 0) then b: =a mod 10;
a: =a div 10;
if (a mod 10 < b) and (a mod 2 = 0) then b: =a mod 10;
a: =a div 10;
if (a mod 10 < b) and (a mod 2 = 0) then b: =a mod 10;
if b mod 2=0 then writeln(b)else writeln('-1');
end.