問題一覧 > 通常問題

No.996 Phnom Penh

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 128 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 34
作問者 : ganmodokix / テスター : monkukui2
お気に入りにしたユーザー ProblemId : 3338 / 自分の提出
問題文最終更新日: 2020-03-08 16:57:15
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 238 (順位表) の他の問題:

Problem Statement

You are given a string $S$. You may perform the following operations on this string any number of times, in any order.

  • Operation 1: Choose one occurrence of "phnom" contained in $S$ as a contiguous substring, and replace it with "penh".
  • Operation 2: Erase all "h" contained in $S$, and then replace all "e" with "h".

However, if the string would not change between before and after an operation, that operation cannot be performed.

Find the maximum number of operations you can perform on the string $S$.

Input

$S$

The input also satisfies the following constraints.

  • $S$ is a string consisting only of lowercase English letters
  • $1 \le |S| \le 2 \times 10^5$

Output

Print the maximum number of operations, followed by a newline.

Sample

Sample 1
Input
phnompenh
Output
3

The maximum number of operations, $3$, can be achieved by operating as follows.

  • Operation 1. "phnompenh"$\to$"penhpenh"
  • Operation 2. "penhpenh"$\to$"phnphn"
  • Operation 2. "phnphn"$\to$"pnpn"
Sample 2
Input
phnomom
Output
5

The maximum number of operations, $5$, can be achieved by operating as follows.

  • Operation 1. "phnomom"$\to$"penhom"
  • Operation 2. "penhom"$\to$"phnom"
  • Operation 1. "phnom"$\to$"penh"
  • Operation 2. "penh"$\to$"phn"
  • Operation 2. "phn"$\to$"pn"
Sample 3
Input
pepenhomom
Output
6

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。