P24369 [AtCoder] "redocta".swap(i,i+1)
普及-
题目描述

Problem Statement

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

  • Choose two adjacent characters of S and swap them.

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

Input

Input is given from Standard Input in the following format:
S

Output

Print the answer as an integer.

Constraints

  • S is a string that is a permutation of atcoder

Sample Input 1

catredo

Sample Output 1

8

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

Sample Input 2

atcoder

Sample Output 2

0

In this case, the string S is already atcoder.

Sample Input 3

redocta

Sample Output 3

21

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
catredo
样例输出
8