P5690 [CSP-S 2019 Jiangxi] Date
Background
CSP-SJX2019 T1
Description
Alice wrote a date on paper in the form $\text{MM-DD}$, where $\text{MM}$ and $\text{DD}$ are both two-digit numbers representing the month and the day, respectively. However, this date may not actually exist. Alice asked Bob to change the digits in some positions so that the date becomes valid. Please help Bob compute the minimum number of digits he needs to change.
In this problem, February is fixed to have $28$ days.
Input Format
A single line containing a string of five characters, representing $\text{MM-DD}$.
Output Format
A single line containing one integer, representing the answer.
Explanation/Hint
[Explanation for Sample Input/Output 1]
There is more than one way to change it. One possible result is: $\text{03-22}$.
[Explanation for Sample Input/Output 2]
One possible result is: $\text{02-09}$.
[Explanation for Sample Input/Output 3]
One possible result is: $\text{07-09}$.
[Constraints]
For $100\%$ of the testdata, $\text{MM}$ and $\text{DD}$ are guaranteed to be $4$ digits.
**update: 2024/07/04 Added one hack case.**
Translated by ChatGPT 5