Problem list
Log in
#r03755 · COI 2008

Umnozak

Diamond V 1.0 s 100 MB

The dig$it-pr$oduct of a positive integer is the product of the number's decimal digits. For example, the dig$it-pr$oduct of 2612 is $2 \cdot 6 \cdot 1 \cdot 2 = 24$. The se$lf-pr$oduct of a number is the product of the number and its dig$it-pr$oduct. For example, the se$lf-pr$oduct of 2612 is $2612 \cdot 24 = 62688$. Write a program that, given two positive integers A and B, calculates the number of positive integers whose se$lf-pr$oduct is between A and B, inclusive.

Input

The first and only line contains two integers A and B ($1 \le A \le B < 10^{18}$).

Output

Output should consist of a single integer, the number of positive integers whose twist is between A and B.

Constraints

In test cases worth a total of 25 points, A and B will be at most $10^{8}$. In test cases worth another 15, A and B will be at most $10^{12}$.

Example 1

Input
20 30
Output
2

Example 2

Input
145 192
Output
4

Example 3

Input
2224222 2224222
Output
1

Clarification of second example. The self-products of numbers 19, 24, 32 i 41 are in order 171, 192, 192 and 164.

Source
COI 2008
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code