#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 11 line: containing a string SS, where the string length lenlen (1len10001≤len≤1000).

Output Format

The output consists of 11 line, containing 11 number representing the total cost of the stable lexicographical sort of the string.

Sample

chuan
8