#abc264d. [abc264_d]"redocta".swap(i,i+1)
[abc264_d]"redocta".swap(i,i+1)
Problem Statement
You are given a string that is a permutation of atcoder
.
On this string , you will perform the following operation or more times:
- Choose two adjacent characters of and swap them.
Find the minimum number of operations required to make equal atcoder
.
Constraints
- is a string that is a permutation of
atcoder
Input
Input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
catredo
Sample Output 1
8
You can make equal atcoder
in 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.
Sample Input 2
atcoder
Sample Output 2
0
In this case, the string is already atcoder
.
Sample Input 3
redocta
Sample Output 3
21