Program n_1;
var x, i, s: integer; a: array[1..3] of integer;
begin
read(a[1], a[2], a[3]);
for i:=1 to 3 do begin
s:=0;
x:=a[i];
while x>0 do begin
s:=s+x mod 10;
x:=x div 10;
end;
if (s mod 3 = 0) and (a[i] mod 2 = 0) then write(a[i], ' ');
end;
end.