{$MINSTACKSIZE $00004000}
{$MAXSTACKSIZE $00200000}
program prC;
{$APPTYPE CONSOLE}

 var s: string;
     i: integer;
     Tree: array[1..50000, 0..15] of integer;
     Stack: array[0..50000] of integer;
     Sl, Tl: integer;
     resS: string;
     resD: integer;


 procedure BuildTree(Top: integer; var s:string; var maxd: integer);
   var strs: array[0..9] of string;
       depths: array[0..9] of integer;
       i, j, k, l: integer;
       cmaxD: Integer;

  begin
   if Tree[Top, 0] = 0 then
    begin
     s := 'a';
     maxd := 1;
     exit;
    end;
   l := Tree[Top, 0];
   for i := 1 to l do
    BuildTree(Tree[Top, i], strs[i - 1], depths[i - 1]);
   maxD := 10000000;
   for i := 0 to l -  1 do
   begin
     cmaxD := depths[i];
     for j := 0 to l - 1 do
       if depths[(i + j) mod l] + j > cmaxD then cmaxD := depths[(i + j) mod l] + j;
     if cmaxD < maxD then
     begin
       maxD := cmaxD;
       k := i;
     end;
   end;
   s:='';
   for i := 0 to l - 1 do
    s := s + strs[(k + i) mod l];
   s := s + chr(ord('0') + l);
  end;

  var k,j, Top :integer;
begin
 assign(input, 'chandelier.in');
 reset(input);
 assign(output, 'chandelier.out');
 rewrite(output);

 fillchar(Tree, sizeof(tree), 0);

 readln(s);
 SL := 0;
 TL := 0;
 for i := 1 to length(S) do
  begin
   if s[i] = 'a' then
    begin
     Inc(TL);
     Stack[SL] := TL;
     inc(SL);
    end
   else
    begin
     inc(TL);
     k := ord(s[i]) - ord('0');
     for j := 1 to k do
     Tree[TL, j] := Stack[SL - k + j - 1];
     Tree[TL, 0] := k;
     dec(SL, k);
     Stack[SL] := TL;
     inc(SL);
    end;
  end;
 Top := Stack[0];
 BuildTree(Top, resS, resD);
 writeln(resD);
 writeln(resS);
end.
