offence

AtCoder
IDabc325_g
Time2000ms
Memory256MB
Difficulty
You are given a string $S$. Find the minimum length of a string that can be obtained by performing the following operation on the string $S$ zero or more times. * Choose a contiguous occurrence of `of` in the string and an integer $i$ between $0$ and $K$, inclusive. Then, remove the `of` and the following $i$ characters from the string. ## Constraints * $0 \leq K < |S| \leq 300$ * $K$ is an integer. * $S$ is a string consisting of lowercase English letters. ## Input The input is given from Standard Input in the following format: $S$ $K$ [samples]
Samples
Input #1
keyofscience
3
Output #1
7

By choosing the `of` formed by the fourth and fifth characters and setting $i = 3$, you can remove `ofsci` from `keyofscience` and get `keyence`.  
It is impossible to reduce the length of the string to $6$ or less by repeating the operation, so the answer is $7$.
Input #2
oofsifffence
3
Output #2
2
Input #3
ooofff
5
Output #3
0
Input #4
okeyencef
4
Output #4
9
API Response (JSON)
{
  "problem": {
    "name": "offence",
    "description": {
      "content": "You are given a string $S$. Find the minimum length of a string that can be obtained by performing the following operation on the string $S$ zero or more times. *   Choose a contiguous occurrence of ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc325_g"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a string $S$. Find the minimum length of a string that can be obtained by performing the following operation on the string $S$ zero or more times.\n\n*   Choose a contiguous occurrence of ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments