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.
Comments
I don't understand why I get 0/4 on batch #1 but 6/6 for batch #2
I know 4 of the points has a test case where there are no $25 coins, but I tried all the possible test cases I can think of and they all pass. Can anyone recommend any test cases?
If you remove your debug prints on your latest solution, you pass. In the future, you can join the DMOJ Discord if you have any problems you need help with.