{$I-,Q-,R-,S-,D-,L-,O+}
{I+,Q+,R+,S+,D+,L+,O-}
program C;
{$APPTYPE CONSOLE}
const
  inf = 'chandelier.in';
  ouf = 'chandelier.out';
  maxn = 10002;

type
  int = longint;

{$H+}
var
  ans, s : string;
  stack : array [1..10002] of char;
  max, tmp, i, z, n, m, ss : int;

begin
  assign(input, inf);
  reset(input);
  readln(s);
  close(input);
  ans := '';
  i := 1;
  while i <= length(s) do begin
    if s[i] in ['1'..'9'] then begin
      tmp := byte(s[i]) - 48;
      if i >= tmp + 1 then begin
        ans := ans + copy(s, i - tmp, tmp + 1);
        delete(s, i - tmp, tmp + 1);
        dec(i, tmp + 1);
      end else begin
        ans := ans + copy(s, 1, i);
        delete(s, 1, i);
        i := 0;
      end;
    end;
    inc(i);
  end;
  i := 1;
  ss := 0;
  max := 0;
  while i <= length(ans) do begin
    if ans[i] = 'a' then begin
      inc(ss);
      if ss > max then max := ss;
    end else begin
      dec(ss, (ord(ans[i]) - 48) - 1)
    end;
    inc(i);
  end;
  assign(output, ouf);
  rewrite(output);
  writeln(max);
  writeln(ans);
  close(output);
end.
