시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB146423027.523%

문제

Strings of yarn have been popular in Catland for ages. Which cat has not spent many a lazy afternoon bouncing around a ball of yarn? Lately however, strings of yarn have gotten competition: strings of characters. It turns out that these are almost as much fun as yarn, and generally much safer as well (so far, no cat has had to call 911 on account of any character string-related entanglement accidents).

Naturally, some strings are more stylish than others, and for cool cats it is important to engage in their string-playing pastime with style. The meow factor of a string S is the minimum number of operations needed to transform S into a string S 0 which contains the word “meow” as a substring, where an operation is one of the following four:

  1. Insert an arbitrary character anywhere into the string.
  2. Delete an arbitrary character anywhere from the string.
  3. Replace any character in the string by an arbitrary character.
  4. Swap any two adjacent characters in the string.

Write a program to compute the meow factor of a string of characters.

입력

The input consists of a single line containing a string S, consisting only of lower-case letters ‘a’-‘z’. The length of S is at least 1 and at most 106.

출력

Output the meow factor of S.

예제 입력 1

pastimeofwhimsy

예제 출력 1

1

예제 입력 2

yarn

예제 출력 2

4

출처

Contest > KTH Challenge > KTH Challenge 2019 D번

  • 문제를 만든 사람: Per Austrin