Many databases store character fields (and especially indices) using prefix compression. This technique compresses a sequence of strings A1,A2,…,AN as follows.
The first string A1 is stored in full. For every subsequent string Ai+1, let j be the length of the longest common prefix it shares with the previous string Ai — the largest j≤min(p,q) such that the first j characters of Ai=ai,1ai,2⋯ai,p and Ai+1=ai+1,1ai+1,2⋯ai+1,q are equal. Then Ai+1 is stored as a single control character whose code is j, followed by the remaining characters ai+1,j+1ai+1,j+2⋯ai+1,q. Its stored length is therefore 1+(q−j).
If j=0 (the two strings have no common prefix), the string is still prefixed by one control byte, so its stored length is one greater than its original length.
Compute the minimal total stored length of the whole sequence.
The first line contains an integer N. Each of the next N lines contains one string Ai.
Print a single integer: the minimal total length of the compressed strings.