Module: Bor


Problem

10 /10


Short code

Problem

Evan's code contains n variables. Each variable has a unique name, consisting only of English lowercase (small) letters. One day Evan decided to shorten his code.

He wants to replace the name of each variable with its non-empty prefix in such a way that the new names remain pairwise distinct (but the new name of some variable may be the same as the old name of this or another variable). Among all such possible replacements, he wants to find one for which the total length of variable names will be minimal.

The string a is a prefix of the string b if you can remove some (possibly none) characters from the end of the string b and get a.

Find the minimum possible total length of new names.

Input:
The first line contains a single integer n (1 ≤ n ≤ 105) — number of variables in Evan's code.

The next n lines contain variable names, one per line. Each name is not an empty string and contains only lowercase (small) English letters. The total length of all these strings is no more than 105. All variable names are different.

Output:
Print a single integer — the minimum possible total length of new variable names.

Examples:
 
Input Output
3


code
6
5
abba
abb
ab
aa
aacada
11
3
telegram
digital
resistance
3

Explanations:
In the first example, one of the best options would be to shorten the names in the order they are entered to "cod", "co", "c".
In the second example, you can shorten the last name to "aac" and first name before "a" without changing other variable names.