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

AtCoder
IDabc264_d
Time2000ms
Memory256MB
Difficulty
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: $S$ [samples]
Samples
Input #1
catredo
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.
Input #2
atcoder
Output #2
0

In this case, the string $S$ is already `atcoder`.
Input #3
redocta
Output #3
21
API Response (JSON)
{
  "problem": {
    "name": "\"redocta\".swap(i,i+1)",
    "description": {
      "content": "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 the",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc264_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a string $S$ that is a permutation of `atcoder`.  \nOn this string $S$, you will perform the following operation $0$ or more times:\n\n*   Choose two adjacent characters of $S$ and swap the...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments