#abc264d. [abc264_d]"redocta".swap(i,i+1)

[abc264_d]"redocta".swap(i,i+1)

Problem Statement

You are given a string SS that is a permutation of atcoder.
On this string SS, you will perform the following operation 00 or more times:

  • Choose two adjacent characters of SS and swap them.

Find the minimum number of operations required to make SS equal atcoder.

Constraints

  • SS is a string that is a permutation of atcoder

Input

Input is given from Standard Input in the following format:

SS

Output

Print the answer as an integer.


Sample Input 1

catredo

Sample Output 1

8

You can make SS equal atcoder in 88 operations as follows:
catredo rightarrow\\rightarrow [ac]tredo rightarrow\\rightarrow actre[od] rightarrow\\rightarrow actr[oe]d rightarrow\\rightarrow actro[de] rightarrow\\rightarrow act[or]de rightarrow\\rightarrow acto[dr]e rightarrow\\rightarrow a[tc]odre rightarrow\\rightarrow atcod[er]
This is the minimum number of operations achievable.


Sample Input 2

atcoder

Sample Output 2

0

In this case, the string SS is already atcoder.


Sample Input 3

redocta

Sample Output 3

21