Problem: You are given strings , consisting of lowercase Latin letters. Let be the length of string .
Let a collapse of two strings and be the following operation:
- if is empty, ;
- if is empty, ;
- if the last letter of is equal to the first letter of , then , where is the substring of from the -th letter to the -th one;
- otherwise, , i. e. the concatenation of two strings.
Calculate .
Input Format: The first line contains a single integer ().
Each of the next lines contains a string (), consisting of lowercase Latin letters.
The total length of the strings doesn't exceed .
Output Format: Print a single integer — .