Codeforces Round 476 (Div. 2) [Thanks, Telegram!]
E
Short Code
Codeforces
2200
原题
← D→
翻译中…

Arkady's code contains $n$ variables. Each variable has a unique name consisting of lowercase English letters only. One day Arkady decided to shorten his code.

翻译中…

He wants to replace each variable name with its non-empty prefix so that these new names are still unique (however, a new name of some variable can coincide with some old name of another or same variable). Among such possibilities he wants to find the way with the smallest possible total length of the new names.

翻译中…

A string $a$ is a prefix of a string $b$ if you can delete some (possibly none) characters from the end of $b$ and obtain $a$.

翻译中…

Please find this minimum possible total length of new names.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($1 \le n \le 10^5$) — the number of variables.

翻译中…

The next $n$ lines contain variable names, one per line. Each name is non-empty and contains only lowercase English letters. The total length of these strings is not greater than $10^5$. The variable names are distinct.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

In the first example one of the best options is to shorten the names in the given order as "cod", "co", "c".

翻译中…

In the second example we can shorten the last name to "aac" and the first name to "a" without changing the other names.

翻译中…

样例

Input #1
3
codeforces
codehorses
code
Output #1
6
InputCopy OutputCopy
Input #2
5
abba
abb
ab
aa
aacada
Output #2
11
InputCopy OutputCopy
Input #3
3
telegram
digital
resistance
Output #3
3
InputCopy OutputCopy
题目信息
题号
965E
时间限制
1 s
内存限制
256 MB
标签
数据结构
动态规划
贪心
字符串
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。