{$o-,q+,r+}
{ $o+,q-,r-}
{$MINSTACKSIZE $00004000}
{$APPTYPE console}
uses
    sysutils;
type
    int = longint;
const
    finname = 'chandelier';
    maxn = 10000;
var
    a, p: array[1 .. maxn] of int;
    e, es: array[1 .. maxn, 1 .. 20] of int;
function count(x: int): int;
var
    i, t, j: int;
begin
    if (a[x] = 1) then begin
        result := 1;
        exit;
    end;
    for i := 1 to a[x] do begin
        es[x, i] := count(e[x, i]);
        es[x, i + a[x]] := es[x, i];
    end;
    p[x] := -1;
    for i := 1 to a[x] do begin
        t := 0;
        for j := 0 to a[x] - 1 do
            if (t < j + es[x, i + j]) then
                t := j + es[x, i + j];
        if (p[x] = -1) or (t < result) then begin
            p[x] := i;
            result := t;
        end
    end;
end;
procedure outp(x: int);
var
    i: int;
begin
    if (a[x] = 1) then begin
        write('a');
        exit;
    end;
    for i := p[x] to p[x] + a[x] - 1 do
        outp(e[x, i]);
    write(a[x]);
end;
var
    ch: char;
    m, na, i, j: int;
    s: array[1 .. maxn] of int;
begin
    reset(input, finname + '.in');
    rewrite(output, finname + '.out');

    na := 0;
    while (not seekeof) do begin
        read(ch);
        inc(na);
        if (ch = 'a') then
            a[na] := 1
        else
            a[na] := ord(ch) - ord('0');
    end;

    m := 0;

    for i := 1 to na do begin
        if (a[i] = 1) then begin
            inc(m);
            s[m] := i;
            continue;
        end;
        for j := m - a[i] + 1 to m do
            e[i, j - m + a[i]] := s[j];
        for j := 1 to a[i] - 1 do
            e[i, j + a[i]] := e[i, j];
        m := m - a[i] + 1;
        s[m] := i;
    end;

    writeln(count(na));
    outp(na);

end.