program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils, Strutils;

function Equality(const s1, s2: string): integer;
var i: integer;
begin
  Result := 0;
  if (s2 = '') or (s1 = '') then Exit;
  i:=1;
  while s1[i] = s2[i] do begin
   inc(result);
   inc(i);
  end;
end;

var ifile, ofile: TextFile;
    i, count, len, res: Integer;
    s: array [0..10000] of string;

begin

  AssignFile(ifile, 'input.txt');
  Reset(ifile);
  Readln(ifile, count);

  for i := 1 to count do Readln(ifile, s[i]);
  s[0] := '';

  for i := count downto 2 do begin
   if (Equality(s[i], s[i-1]) >= Equality(s[i-1], s[i-2])) and (pos('_=!@', s[i+1])=0) then begin
    Delete(s[i], 1, Equality(s[i], s[i-1]));
    insert('1', s[i], 1);
    s[i] := s[i] + '_=!@';
   end;
  end;

  for i := 1 to count do inc(res, length(stringreplace(s[i], '_=!@' ,'', [rfReplaceAll])));

  if count = 1 then res := length(s[1]);

  AssignFile(ofile, 'output.txt');
  Rewrite(ofile);
  Write(ofile, res);
  CLoseFile(ofile);
  CloseFile(ifile);

end.
