#t460. 单词查找树
单词查找树
Background
Special for beginners, ^_^
Description
When performing grammar analysis, one usually needs to check whether a given word appears in our word list. To speed up searching and locating, we build a word search tree (a trie) corresponding to the word list. It has the following properties:
-
The root node contains no letter; except for the root, every node contains exactly one uppercase English letter;
-
Reading the letters along the path from the root to a given node and concatenating them in order forms the word corresponding to that node. Every word in the word list is the word corresponding to some node of the tree;
-
Subject to the conditions above, the number of nodes of the word search tree is minimized.
-
For example, the word list on the left of the figure corresponds to the word search tree on the right. Given a fixed word list, count the number of nodes of the corresponding word search tree (including the root node).

Format
Input
The input is a word list; each line contains exactly one word followed by a line feed / carriage return. Each word consists only of uppercase English letters and has length at most 63. The total length of the file does not exceed 32K, and there is at least one line of data.
Output
Output a single integer: the number of nodes of the word search tree corresponding to the word list.
Samples
A
AN
ASP
AS
ASC
ASCII
BAS
BASIC
13
Limitation
1s, 1024KiB for each test case.