9802: ABC264 —— D - "redocta".swap(i,i+1)
[Creator : ]
Description
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`.
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$
```
```
$S$
```
Output
Print the answer as an integer.
Constraints
- $S$ is a string that is a permutation of `atcoder`
Sample 1 Input
catredo
Sample 1 Output
8
You can make S equal atcoder in 8 operations as follows:
catredo → [ac]tredo → actre[od] → actr[oe]d → actro[de] → act[or]de → acto[dr]e → a[tc]odre → atcod[er]
This is the minimum number of operations achievable.
catredo → [ac]tredo → actre[od] → actr[oe]d → actro[de] → act[or]de → acto[dr]e → a[tc]odre → atcod[er]
This is the minimum number of operations achievable.
Sample 2 Input
atcoder
Sample 2 Output
0
Sample 3 Input
redocta
Sample 3 Output
21