QOJ.ac

QOJ

Time Limit: 8 s Memory Limit: 512 MB Total points: 10

#1377. Potyczkowa Number

Statistics

During a history of mathematics class, Bajtek learned about a Russian mathematician named Vladimir Potyczkowie. This famous scholar became known for describing numbers that we now call "Potyczkowa numbers" in his honor.

A Potyczkowa number is defined as any positive integer that is divisible by each of the digits in its decimal representation. In particular, this means that its decimal representation cannot contain any zeros. For example, 48, 1, and 112 are Potyczkowa numbers, while 23, 10, and 121 are not.

Bajtek is wondering how many Potyczkowa numbers exist. He is curious how many such numbers there are in the interval $[l, r]$. Help him count them!

Input

The only line of standard input contains two integers $l$ and $r$ ($1 \le l \le r < 10^{18}$).

Output

The output should contain a single integer equal to the number of Potyczkowa numbers in the interval $[l, r]$.

Examples

Input 1

1 100

Output 1

23

Note

The Potyczkowa numbers not greater than 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.

Subtasks

In some test groups, $r - l \le 10^6$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.