P5755 [NOI2000] Word Lookup Tree.

Description

When doing grammar analysis, we usually need to check whether a word is in our word list. To improve the speed of searching and locating, we often build a word lookup tree corresponding to the word list, with the following features: - The root node contains no letter. Every node except the root contains exactly one uppercase English letter. - For any node, the sequence of letters along the path from the root to that node, concatenated in order, is called the word corresponding to that node. Every word in the word list is the word corresponding to some node in the word lookup tree. - Under the above conditions, the word lookup tree has the minimum possible number of nodes. Example: the word list in Figure 1 corresponds to the word lookup tree in Figure 2. ![](https://cdn.luogu.com.cn/upload/image_hosting/zolscsb0.png) For a given word list, count the number of nodes in the corresponding word lookup tree (including the root node).

Input Format

A word list, one word per line. Each word consists only of uppercase English letters and has length at most $63$. The total file length does not exceed 32K. There is at least one line of data.

Output Format

Output a single integer. This integer is the number of nodes in the word lookup tree corresponding to the word list.

Explanation/Hint

Translated by ChatGPT 5