Simple prefix compression#4527

Simple prefix compression

1 second
64 megabytes
Easy

Many databases store data in character fields, especially indices, using prefix compression. This technique compresses a sequence of strings A_1, \ldots, A_N as follows: given two strings

A_i = a_{i,1}a_{i,2}\ldots a_{i,p} \quad \text{and} \quad A_{i+1} = a_{i+1,1}a_{i+1,2}\ldots a_{i+1,q}

suppose for some j \leq \min(p, q) it holds that a_{i,1} = a_{i+1,1}, a_{i,2} = a_{i+1,2}, , a_{i,j} = a_{i+1,j}. Then, the second string is stored as [j]a_{i+1,j+1}a_{i+1,j+2}\ldots a_{i+1,q}, where is a single character with code .

If j = 0, i.e., the strings do not have any common prefix, then a zero byte is prefixed to the second string, thus actually increasing the total length.

Input

The first line contains an integer (1 \leq N \leq 10000). The next lines each contain a string A_i (1 \leq \text{length}(A_i) \leq 255).

Output

Output a single integer — the minimal total length of the compressed strings.

Examples

Example 1

Loading
Loading