{$apptype console}

program chandelier;

const
                infile='chandelier.in';
                outfile='chandelier.out';
                maxn=10001;

type
                int=longint;
                node=array [1..maxn] of char;

var
                a,b,c           :node;
                n,k,max         :int;

procedure load;
var
        i,j,p,r:int;
        ch:char;
        code:integer;
begin
  assign(input,infile);
  reset(input);
  max:=0;
  k:=0;
  n:=0;
  while not seekeoln(input) do begin
    read(ch);
    if ch in ['1'..'9'] then begin
      val(ch,i,code);
      if i+1>max then max:=i+1;
      c:=a;
      r:=k;
      j:=k-(max-1);
      k:=k-(max-1);
      for p:=j+1 to r do
       if c[p] in ['1'..'9'] then begin
         inc(k);
         a[k]:=c[p];
        end
        else begin
               inc(n);
               b[n]:=c[p];
             end;
       inc(n);
       b[n]:=ch;
       inc(k);
       a[k]:=ch;      
     end
    else begin
           inc(k);
           a[k]:=ch;
         end;
   end;
  close(input);
end;

procedure print;
var
        i:int;
begin
  assign(output,outfile);
  rewrite(output);
  writeln(max);
  for i:=1 to n do write(b[i]);
  close(output);
end;

begin
  load;
  print;
end.
