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

2402: "redocta".swap(i,i+1)

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

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 Copy

catredo

Sample Output Copy

8

HINT

You can make SS equal atcoder in 88 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.

Source/Category