1201 - Czyptoghophy

Time Limit: 5s Memory Limit: 1024MB

Submissions: 38 Solved: 9
Czyhd and Ghost always chat through the Internet. But IM software is unsafe , so they invented an encryption method called Czytoghophy. A message is a sentence,in other words,a message is a series of words separated by space. Ghost write a message and encrypt the message using the Czytoghophy method: 1. For each word “A1A2...An” (An is a char) in the message. Choose an integer o . The encrypted word will be “AoAo+1....AnA1A2...Ao-1” , for example the word is “czyhd” and o = 3 then we get an encrypted word “yhdcz”. 2. Encrypt the message from the first word to the last word. For each tow consecutive words (Namely A and B , and A is in front of B), remove the space between A and B and a suffix of A which is one of prefixes of B. For example , message “hello czyhd” can be encryted into “elloh hdczy” after the first step. And then we encryted it into “ellohdczy” . We can easily know that the encrypted message is not unique for a given message .As we know , Ghost is a lazy guy . If there is a shorter encrypted text , he would never type a longer one, so he wants to know the minimum length of the encrypted message for a give message.
The data file have several cases. In each case,there is only line of message . The number of words in each case is no more than 200 and the length of each word is no more than 200.
For each case , print an integer , that is the minimum length of the encrypted message of the message given in the input case.
Sample Input
hello czyhd
czyhd czyhd czyhd come out
xx make me cry
ll is a big rubbish i hate it
Sample Output
For 1st case , encrypted message is “ellohdczy” For 2nd case , encrypted message is “zyhdcomeout” For 3rd case , encrypted message is “xxakemcry” For 3rd case , encrypted message is “llisagbishrubiehati” We cannot encrypt “ab cd abcd” into “abcd ”.