#P10024. 「HCOI-R1」报名人数
「HCOI-R1」报名人数
Background
On an electronic display board, for a decimal number , from right to left, from the lowest digit of to the highest digit, we show each digit in the following way:

So, for digits , the numbers of short vertical segments used for each digit are , respectively.
Problem Description
There is a large electronic display board in Xiao R's home, which records the number of registrations for HCOI-R1.
When Xiao R finished setting it up, the number of registrations for HCOI-R1 was . Now, the final number of registrations for HCOI-R1 is .
Xiao R considers an integer pair to be lucky if and only if, during the registration process, there exists a period when the number of registrations was (that is, ), and, without leading , the numbers of short vertical segments used to display are the same.
Xiao R wants to know: among all lucky pairs , what is the maximum possible value of , that is, the number of integers.
Input Format
Only one line containing two integers , representing the initial number of registrations and the final number of registrations.
Output Format
One line containing one integer, representing the maximum value of among all pairs .
2 5
2
114514 114514
1
Hint
Sample Explanation 1
There is a lucky pair , meaning they both need short vertical segments.
Constraints
This problem uses bundled testdata.
- Subtask 0 (19 pts): .
- Subtask 1 (33 pts): .
- Subtask 2 (48 pts): no special constraints.
For all testdata, it is guaranteed that .
Translated by ChatGPT 5