program xx;
const inp='chandelier.in';
     outp='chandelier.out';
var a,c,xa:array [1..10000] of longint;
    b:array [1..10000] of string;
    n:longint;
    s,s1:string;
    x:integer;
procedure rec(n:integer);
var k,p,w,e,r,t:longint;
begin
 if n=0 then exit;
 if s[n]='a'
    then begin
          a[n]:=1; b[n]:='a';
          c[n]:=1;
          exit;
         end;
 val(s[n],w,x); e:=n-1;
 for k:=1 to w do
  begin
   rec(e);
   if s[e]='a'
      then e:=e-1
      else e:=e-c[e];
  end;
 c[n]:=0; e:=n-1;
 for k:=1 to w do
  begin
   xa[k]:=e;
   c[n]:=c[n]+c[e];
   if s[e]='a'
      then e:=e-1
      else e:=e-c[e];
  end;
 for k:=1 to w div 2 do
  begin
   e:=xa[k];
   xa[k]:=xa[w-k+1];
   xa[w-k+1]:=e;
  end;
 a[n]:=maxlongint;
 for k:=1 to w do
  begin
   e:=0;
   for p:=k to w do
    if e<p-k+a[xa[p]]
       then e:=p-k+a[xa[p]];
   for p:=1 to k-1 do
    if e<p+(w-k)+a[xa[p]]
       then e:=p+(w-k)+a[xa[p]];
   if a[n]>e
      then begin
            a[n]:=e;
            t:=k;
           end;
  end;
 b[n]:='';
 for k:=t to w do b[n]:=b[n]+b[xa[k]];
 for k:=1 to t-1 do
     b[n]:=b[n]+b[xa[k]];
 inc(c[n]);
 b[n]:=b[n]+s[n];
end;
begin
 assign(input,inp); reset(input);
 assign(output,outp); rewrite(output);
 readln(input,s);
 rec(length(s));
 writeln(output,a[length(s)]);
 writeln(output,b[length(s)]);
 close(input); close(output);
end.
