Skip to main content
Back to problems
Codeforces
Easy
Strings
Simulation
Inna and Pink Pony

Count how many times the word "Pinkie Pie" appears after replacing each occurrence of "pink" with "pinkie" in a given string.

Acceptance 0%
Also Available On
Other platform versions and source mappings for the same problem.
Problem Statement

Problem

You are given a string consisting of lowercase English letters. In the string, every occurrence of the substring pink can be replaced by pinkie. Your task is to determine how many times the string pinkie pie appears after all such replacements are performed.

A valid occurrence is counted whenever the substring pinkie pie appears in the final transformed text. Replacements may create new matches that should also be considered as part of the final result.

Task

Find the number of occurrences of pinkie pie that can be obtained from the given string according to the rule above.

Input Format

  • A single line containing a string s.
  • The string contains only lowercase English letters.

Output Format

  • Print one integer: the number of occurrences of pinkie pie after applying the transformation rule.

Constraints

  • 1 <= |s| <= $10^{5}$
  • s contains only lowercase English letters
  • The transformation is interpreted on the full string, not by overlapping partial replacements
Examples
Sample cases returned by the problem API.

Example 1

Input

pink

Output

1

Explanation

The string can be transformed into pinkie pie, so there is exactly one occurrence.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.