## UCC Coding Competition '21 P1 - Counterfeit Detection

View as PDF

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

In your strange local currency, there should only be , and coins. Unfortunately, a counterfeiter just added a whole bunch of fake coins into circulation!

Your job is to determine how many counterfeited coins are mixed into a row of coins. This is more difficult than it looks. The coins are rectangular, so a row of coins looks something like this:

In order to count all the coins, you use a scanning machine that reads the digits on the top of the coins one by one. For the row of coins shown above, your machine will produce the string 622544252.

Given a sequence of digits generated by the machine, please determine how many of the coins are counterfeit coins. As there are no coins in circulation, you can assume that if you see 25 in the sequence, it represents a non-counterfeit coin. Otherwise, if you see a 2 in the sequence that is not followed by a 5, you can assume that it is a counterfeit coin.

#### Input Specification

The first and only line of input will contain a sequence of digits from your coin-scanning machine, such as 622544252.

#### Output Specification

Please output the number of counterfeit () coins in the row of coins.

#### Constraints and Partial Marks

For all test cases, the string is characters or fewer in length.

Additionally, for out of available marks, there are no coins, so the string doesn't contain the digit 5.

#### Sample Input

2256624425252

#### Sample Output

3

#### Explanation for Sample Output

The sample input represents this row of coins:

In this row, there are three counterfeit coins.