#AT2272. D - "redocta".swap(i,i+1)

D - "redocta".swap(i,i+1)

当前没有测试数据。

D - "redocta".swap(i,i+1)

Score : $400$ points

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.

Constraints

  • $S$ 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.


catredo
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.


atcoder
0

In this case, the string $S$ is already atcoder.


redocta
21