uses
  SysUtils;

type pTT = ^TT;
     TT = record
            Leaf: boolean;
            Compl: integer;
            Child: array [1..9] of pTT;
            ChCount: integer;
            Ps: integer;
          end;

var S: string;
    I: integer;
    St: array [1..100100] of pTT;
    St1: array [1..100100] of char;
    Top1: integer;
    Top, J: integer;
    Tmp: pTT;


procedure GetCompl(var S: pTT);
var Q, W: integer;
    Arr: array [1..9] of integer;
    Cur, Max, Min, Ps: integer;
    R: integer;
begin
  if S^.Leaf then begin S^.Compl := 1; S^.Ps := 1;end
    else
      begin
        for Q := 1 to S^.ChCount do
          begin
            GetCompl(S^.Child[Q]);
            Arr[Q] := S^.Child[Q]^.Compl;
          end;
        Ps := 1;
        Min := 1000000;
        for Q := 1 to S^.ChCount do
          begin
            Max := 0;
            Cur := 0;
            for W := Q downto 1 do
              begin
                Cur := Cur + Arr[W];
                if Cur > Max then Max := Cur;
                Cur := Cur - Arr[W] + 1;
                if Cur > Max then Max := Cur;
              end;
            for W := S^.ChCount downto Q + 1 do
              begin
                Cur := Cur + Arr[W];
                if Cur > Max then Max := Cur;
                Cur := Cur - Arr[W] + 1;
                if Cur > Max then Max := Cur;
              end;
            if Max < Min then
              begin
                Min := Max;
                Ps := Q;
              end;
          end;
        S^.Compl := Min;
        S^.Ps := Ps;
      end;
end;

procedure FillStack(S: pTT);
var Q, W, Sta: integer;
begin
  if S^.Leaf then begin inc(Top1); St1[Top1] := 'a'; end else
    begin
      Sta := S^.Ps;
      for W := 1 to S^.ChCount do
        begin
          fillStack(S^.Child[Sta]);
          Sta := Sta - 1;
          if Sta = 0 then Sta := S^.ChCount;
        end;
      inc(Top1);
      St1[Top1] := intToStr(S^.ChCount)[1];
    end;

end;

begin
  assignfile(input, 'chandelier.in');
  assignfile(output, 'chandelier.out');
  reset(input);
  rewrite(output);
  readLn(S);
  Top := 0;
  for I := 1 to Length(S) do
    begin
      if S[I] = 'a' then
        begin
          Inc(Top);
          New(Tmp);
          Tmp^.Leaf := TRUE;
          Tmp^.Compl := 1;
          St[Top] := Tmp;
        end;
      if S[I] <> 'a' then
        begin
          New(Tmp);
          Tmp^.Leaf := FALSE;
          Tmp^.ChCount := StrToInt(S[I]);
          for J := 1 to StrToInt(S[I]) do
            Tmp^.Child[J] := St[Top - J + 1];
          Tmp^.Compl := 0;
          Top := Top - StrToInt(S[I]) + 1;
          St[Top] := Tmp;
        end;
    end;
  GetCompl(St[1]);
  Top1 := 0;
  writeln(St[1]^.compl);
  FillStack(St[1]);
  for I := 1 to Top1 do
    write(St1[I]);


  closefile(input);
  closefile(output);
end.
