P9092 [PA 2020] Liczba Potyczkowa

Description

**This problem is translated from [PA 2020](https://sio2.mimuw.edu.pl/c/pa-2020-1/dashboard/) Trial Round [Liczba Potyczkowa](https://sio2.mimuw.edu.pl/c/pa-2020-1/p/lic/).** 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 $0$. For example, $48$, $1$, and $112$ are Potyczkow numbers, while $23$, $10$, and $121$ are not. Bajtek wants to know how many such numbers are in the range $[l, r]$. Please help him count them.

Input Format

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

Output Format

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

Explanation/Hint

#### Explanation for Sample 1 Potyczkow numbers not exceeding $100$ are $1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22, 24, 33, 36, 44, 48, 55, 66, 77, 88$ and $99$. ------------ #### Constraints **This problem uses bundled testdata.** For some subtasks, $r - l \le 10^6$. For $100\%$ of the testdata, it is guaranteed that $1 \le l \le r \le 10^{18}$. Translated by ChatGPT 5