{$R+,Q+,O-}
{$MINSTACKSIZE $00404000}
{$APPTYPE CONSOLE}
type
  int = longint;

var
  s: string;
  link: array[1..10000, 1..9] of int;
  stack: array[1..10000] of int;
  ans: array[1..10000] of int;
  st, i, j, m, l: int;

function solve(c: int): int;
var
  a: array[1..9] of int;
  i, j, m: int;
  s0, s1: int;
begin
  if (s[c] = 'a') then
  begin
    result := 1;
    exit;
  end;
  m := ord(s[c]) - ord('0');
  for i := 1 to m do
  begin
    a[m + 1 - i] := solve(link[c, i]);
  end;
  s1 := -1;
  for i := 1 to m do
  begin
    s0 := 0;
    for j := 1 to m do
    begin
      if (j - 1 + a[(i + j) mod m + 1] > s0) then
        s0 := j - 1 + a[(i + j) mod m + 1];
    end;
    if (s0 < m) then
      s0 := m;
    if (s1 < 0) or (s0 < s1) then
    begin
      s1 := s0;
      ans[c] := i;
    end;
  end;
  solve := s1;
end;

procedure answer(c: int);
var
  j, m: int;
begin
  if (s[c] = 'a') then
  begin
    write('a');
    exit;
  end;
  m := ord(s[c]) - ord('0');
  for j := 1 to m do
  begin
    answer(link[c, m + 1 - ((ans[c] + j) mod m + 1)]);
  end;
  write(s[c]);
end;

begin
  assign(input, 'chandelier.in');
  assign(output, 'chandelier.out');
  reset(input);
  rewrite(output);
  readln(s);
  l := length(s);
  st := 0;
  for i := 1 to l do
  begin
    if (s[i] <> 'a') then
    begin
      m := ord(s[i]) - ord('0');
      for j := 1 to m do
      begin
        link[i, j] := stack[st];
        dec(st);
      end;
    end;
    inc(st);
    stack[st] := i;
  end;
  writeln(solve(l));
  answer(l);
  writeln;
end.
