#P412. 【例71.1】 字典序排序
【例71.1】 字典序排序
Description
Xiao Ming is learning about lexicographical sorting and wants to study the internal structure of stable sorting. He defines a cost as the absolute difference between a character's index before sorting and its index after sorting. Given a string, when sorted lexicographically in ascending order, Xiao Ming calculates the total cost of this stable sort by summing up all the costs. Please design a program to calculate the total cost of this stable sort.
Input Format
The input consists of line: containing a string , where the string length ().
Output Format
The output consists of line, containing number representing the total cost of the stable lexicographical sort of the string.
Sample
chuan8