P28508 [洛谷] [CSP-S2019 Jiangxi] Date
普及
题目描述

Problem Background

CSP-SJX2019 T1

Problem Description

Alice writes down a date in the format $\text{MM-DD}$ on a piece of paper, where $\text{MM}$ and $\text{DD}$ are both two-digit numbers representing the month and day, respectively. However, this date may not necessarily exist. Alice asks Bob to change some digits to make the date valid. Help Bob calculate the minimum number of digits he needs to change.

In this problem, we assume that February always has 28 days.

Input Format

A single line containing a five-character string representing $\text{MM-DD}$.

Output Format

A single line containing an integer representing the answer.

Sample Input and Output

Sample Input #1

03-32

Sample Output #1

1

Sample Input #2

02-39

Sample Output #2

1

Sample Input #3

67-89

Sample Output #3

2

Notes

Sample Input #1 Explanation

There are multiple ways to make the date valid, one of which is changing it to $\text{03-22}$.

Sample Input #2 Explanation

One way to make the date valid is changing it to $\text{02-09}$.

Sample Input #3 Explanation

One way to make the date valid is changing it to $\text{07-09}$.

Data Constraints

For $100\%$ of the data: $\text{MM}$ and $\text{DD}$ are always four digits.

Update: 2024/07/04 Added an additional test case for hacking.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
03-32
样例输出
1