Report - MarisaOJ: Marisa Online Judge

Report

Time limit: 1000 ms
Memory limit: 256 MB
Koakuma has discovered that $n$ books are missing from the library, probably because of Marisa. She needs to write a report for Patchouli listing the missing book names. To keep the report brief, Koakuma can only use the prefixes of the book names. Howerver, no shorten name can be prefixes of two books, or else Patchouli will get confused. For example, if two books have names like `marisa` and `march`, Koakuma can't use `mar` as the name for any of the two books. What is the minimum number of characters that Koakuma must use, given that no book has another book name as a prefix? ### Input - The first line contains an integer $n$. - The next $n$ lines, each line contains a string $|S|$, a book's name, contains only lowercase letters. ### Output - Print the minimum characters Koakuma must use. ### Constraints - $1 \le n \le 10^5$. - $1 \le |S| \le 10^5, \sum{|S|} \le 10^6$. ### Example Input: ``` 2 marisa march ``` Output: ``` 8 ```