var
  q, i, j, k, m, n, p, r: longint;
  s: array [0..101] of string;
  t: string;
begin
{  assign(input, 'input.txt');
  reset(input);
  assign(output, 'output.txt');
  rewrite(output);
  }

  readln(n);
  for i := 1 to n do
    readln(s[i]);

  m := n;
  q := n;
  for i := 1 to length(s[1]) do
  begin
    p := 2;
    for j := 2 to m do
    begin
      if (length(s[j]) >= i) and (s[j][i] = s[1][i]) then
      begin
        t := s[p]; s[p] := s[j]; s[j] := t;
        inc(p);
      end;
    end;
    m := p - 1;
    for j := m + 1 to q do
      for k := j + 1 to q do
        if s[j] > s[k] then
        begin
          t := s[j]; s[j] := s[k]; s[k] := t;
        end;
    q := m;
  end;

  r := length(s[1]);
  for i := 2 to n do
  begin
    j := 1;
    while (length(s[i]) >= j) and (length(s[i-1]) >= j) and
            (s[i][j] = s[i-1][j]) do inc(j);
    r := r + length(s[i]) - j + 1;
  end;

  writeln(r);
  for i := 1 to n do
    writeln(s[i]);
end.
