9116 - DNA Sorting   

Description

Here we consider the string composed of only characters A, C, G, and T. For each character x in the string, we define the unsortedness of x to be the number of characters at the right of x whose alphabetical order is smaller than x.

For example, if the string is ACACA, the unsortedness of the five characters (from left to right) are respectively 0, 2, 0, 1, 0.

The unsortedness score of the whole string is defined to be the sum of the unsortedness of each of its characters.

Given a string, output its unsortedness score.

Input

Input contains multiple testcases. Each case contains one line with a string. The string is formed by four uppercase characters 'A', 'C', 'G', and 'T'. The length of string is less than or equal to 107.

The input is terminated by EOF.

Output

For each case, output a line with the unsortedness score.

Sample Input  Download

Sample Output  Download

Tags




Discuss