P6371 [COCI 2006/2007 #6] V

Description

Using the given digits, form some numbers in $[A, B]$ such that each of these numbers is divisible by $X$.

Input Format

The first line contains three integers $X, A, B$. The second line is a digit string, indicating the digits that can be used. A digit can be used multiple times, and the digits will not be repeated.

Output Format

Output one integer in one line, indicating how many numbers in $[A, B]$ that can be formed using the given digits are divisible by $X$.

Explanation/Hint

#### Constraints - For $100\%$ of the testdata, it is guaranteed that $1 \le X < 10^{11}$, $1 \le A \le B < 10^{11}$. #### Notes **This problem is translated from [COCI2006-2007](https://hsin.hr/coci/archive/2006_2007/) [CONTEST #6](https://hsin.hr/coci/archive/2006_2007/contest6_tasks.pdf) *T5 V***。 Translated by ChatGPT 5