#P9092. [PA 2020] Liczba Potyczkowa

[PA 2020] Liczba Potyczkowa

Problem Description

This problem is translated from PA 2020 Trial Round Liczba Potyczkowa.

In a history of mathematics class, Bajtek learned about a Russian mathematician, Vladimir Potyczkow. This scientist is famous for studying numbers. To honor him, today we call such numbers Potyczkow numbers: they are positive integers and are divisible by every digit that appears in their decimal representation. In particular, this means that their decimal representation cannot contain 00. For example, 4848, 11, and 112112 are Potyczkow numbers, while 2323, 1010, and 121121 are not. Bajtek wants to know how many such numbers are in the range [l,r][l, r]. Please help him count them.

Input Format

One line contains two positive integers l,rl, r.

Output Format

Output one integer on a single line, representing the number of Potyczkow numbers in the range [l,r][l, r].

1 100
23

Hint

Explanation for Sample 1

Potyczkow numbers not exceeding 100100 are $1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22, 24, 33, 36, 44, 48, 55, 66, 77, 88$ and 9999.


Constraints

This problem uses bundled testdata.

For some subtasks, rl106r - l \le 10^6.

For 100%100\% of the testdata, it is guaranteed that 1lr10181 \le l \le r \le 10^{18}.

Translated by ChatGPT 5