program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var

s,old:string;
n,i,j,k,l:integer;
f:text;
begin
assign(f,'input.txt');
reset(f);

readln(f,n);
 readln(f,old);
  l:=length(old);
  s:=old;
for i:=2 to n do
 begin
 old:=s;
 readln(f,s);
 j:=1;
 while (j<=length(s))and(j<=length(old))and(s[j]=old[j]) do
 inc(j);
 dec(j);
  l:=l+length(s)-j+1;
 end;
{for i:=1 to n do
  begin
    readln(f,s);
    k:=0;j:=0;l:=0;
    while(k=0) do
      begin
        inc(j);
        if (length(s)<j) or (length(old)<j) then
          begin
            k:=1;
            break;
          end;
        if s[j]=old[j] then
          begin
            inc(l)
          end
        else begin break; end;
      end;
      writeln(l);
      old:=s;
  end;
}
close(f);
assign(f,'output.txt');
rewrite(f);
write(f,l);
close(f);


end.
