TCCC '24 Feb P2 - Mountain Misfortune

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Java 8 3.0s
Memory limit: 128M

Authors:
Problem type

Thornhill Computer Club 2024 - February Mock CCC - Problem 2

KurbyDoo is climbing up a mountain. Unfortunately he tripped over a rock and is now tumbling down! As he falls, he hits rocks on the way down and each time he does, he screams "OUCH". krem finds KurbyDoo's predicament extremely funny and decides to record the audio. Watching the file back, determine how many times KurbyDoo hit a rock while falling.

Input Specifications

The first and only line of input will consist of a single string of length between 1 to 100000 alphanumeric characters.

Output Specifications

Output a single integer representing the number of times KurbyDoo hit a rock (how many times the string has the word "OUCH").

Sample Input 1

OUCHOUCHOUCH

Sample Output 1

3

Explanation for Sample Output 1

The word "OUCH" can be found 3 times in the given string. This implies that KurbyDoo has hit 3 rocks while falling, thus the output is 3.

Sample Input 2

OUCHOUOUCHKNJGBKRBG

Sample Output 2

2

Explanation for Sample Output 2

The string "OUCH" can only be found twice in the given string as KurbyDoo begins to spout gibberish afterwards.


Comments

There are no comments at the moment.