Strange Shopping

Time Limit: 2 Seconds    Memory Limit: 131072 KB

In the land of Cscience, there are some popular bazaars known as CEzaars in which there are a lot of computer and electronic devices markets. All the markets in a CEzaar are arranged in a straight line next to each other and their name is just an English letter. The name of a CEzaar is built by concatenating markets’ names. For example, a CEzaar with the name “apple” means that there are 5 markets in that CEzaar in a straight line from left to right which their names are “a”, “p”, “p”, “l” and “e”, respectively. There is a computer geek who lives in Cscience and sometimes goes shopping in CEzaars. This man has a strange habit of shopping when he goes to a CEzaar. He comes to the CEzaar from the CEzaar’s left gate, buys a device from each of the markets with distinct names and goes out from the CEzaar’s right gate. If there are multiple markets with the same name, he buys from the left most one. Another important note about him is that he goes through shops in alphabetical order. The cost of going from a market to its adjacent market is 1 and going through gates has no cost. Write a program which computes the total cost of shopping by our computer geek in a specific CEzaar.

Input

First line of the input contains an integer N which is number of test cases. Each of the following N lines contains a string s which is the name of a CEzaar. The string s contains only lowercase English letters and its length does not exceeds 1000.

Output

For each test, print a single line containing the total cost of shopping in the corresponding CEzaar by the computer geek.

Sample Input

3
apple
google
microsoft

Sample Output

10
21
24
Submit