Var
St:String;
Kol_A,Kol_B,i:Byte;
begin
Readln(St);
Kol_A:=0;
Kol_B:=0;
For i:=1 to Length(St) do
Begin
If St[i] = 'A' then Inc(Kol_A);
If St[i] = 'B' then Inc(Kol_B)
End;
Writeln('A = ',Kol_A,' B = ',Kol_B);
Writeln;
If Kol_A > Kol_B then
Begin
While Pos('B',St) > 0 do Delete(St,Pos('B',St),1);
Writeln(St);
End
Else
If Kol_A < Kol_B then
Begin
While Pos('A',St) > 0 do Delete(St,Pos('A',St),1);
Writeln(St);
End
Else Writeln('Ravenstvo simvolov');
Readln
End.