program burning;
var p,q,i,j,k,n,m,h,c,o,l,r:longint;
s:string;
ch:char;
function max(a,b:longint):longint;
begin if (s[i] in['1','2','3','4','5','6','7','8','9','0'])and(k=0) then exit(k);
if b<>0 then exit(k);
exit(1);
end;
procedure num;//处理数字
begin inc(r);
l:=1;
for j:=1 to r do l:=l*10;
k:=k+l*(ord(s[i])-ord('0'));
end;
begin readln(s);r:=-1;
for i:=length(s) downto 1 do
if s[i]='O' then begin o:=o+max(1,k); k:=0; r:=-1;end
else if s[i]='H' then begin h:=h+max(1,k); k:=0; r:=-1; end
else if s[i]='C' then begin c:=c+max(1,k); k:=0; r:=-1;end
else if s[i] in['1','2','3','4','5','6','7','8','9','0'] then num;
while o>0 do begin
if h>=2 then begin dec(o); dec(h); dec(h);inc(q); end;//只处理水就可以AC
end;
repeat//配平
if (o mod 2<>0)or(h mod 4<>0) then begin p:=p*2; h:=h*2; c:=c*2; o:=o*2; q:=q*2 end;
if (o mod 2=0)and(h mod 4=0) then writeln(c+p,' ',h div 2+q);
until (o mod 2=0)and(h mod 4=0);
end.
```(pascal)