program pa;

uses math;

const infile  = 'chandelier.in';
      outfile = 'chandelier.out';
      maxl    = 10000;

var data : array[1..maxl]of char;
    a : array[1..maxl, 0..9]of longint;
    max_ssize : array[1..maxl]of longint;
    n, q : longint;

procedure init;
 begin
  assign(input, infile); reset(input);
  assign(output, outfile); rewrite(output);
  n := 0;
  while not seekeof do begin
    n := n + 1;
    read(data[n]);
   end;
 end;

var t, f : array[1..20]of longint;
    cs : array[1..10]of longint;

procedure go2(id : longint);
var i, j : longint;
 begin
  if a[id, 0] = 0 then begin
    max_ssize[id] := 1;
    exit;
   end;
  for i := 1 to a[id, 0] do go2(a[id, i]);
  for i := 1 to a[id, 0] do begin
    t[i] := max_ssize[a[id, i]]; f[i] := a[id, i];
    t[i + a[id, 0]] := t[i]; f[i + a[id, 0]] := f[i];
   end;
  for i := 1 to a[id, 0] do begin
    cs[i] := a[id, 0];
    for j := 0 to a[id, 0] - 1 do
      cs[i] := max(cs[i], j + t[i + j]);
   end;
  i := 1;
  for j := 2 to a[id, 0] do if cs[j] < cs[i] then i := j;
  for j := i to i + a[id, 0] - 1 do a[id, j - i + 1] := f[j];
  max_ssize[id] := cs[i];
 end;

function go1(id, posit : longint) : longint;
var i, j, k : longint;
 begin
  i := posit;
  if data[i] = 'a' then begin
    a[id, 0] := 0;
    go1 := posit - 1;
    exit;
   end;
  a[id, 0] := ord(data[posit]) - ord('0');
  j := posit - 1;
  for k := a[id, 0] downto 1 do begin
    q := q + 1;
    a[id, k] := q;
    j := go1(q,  j);
   end;
  go1 := j;
 end;

procedure outit(id : longint);
var i : longint;
 begin
  if a[id, 0] = 0 then begin
    write('a');
    exit;
   end;
  for i := 1 to a[id, 0] do outit(a[id, i]);
  write(a[id, 0]); 
 end; 

procedure solve;
 begin
  q := 1;
  go1(1, n);
  go2(1);
 end;

procedure save;
 begin
  writeln(max_ssize[1]);
  outit(1);
  writeln;
  close(output);
 end;

begin
 init;
 solve;
 save;
end.