eolymp
bolt
Try our new interface for solving problems
Problems

Number of Permutations

Number of Permutations

Two distinct positive integers with decimal notations of the same length are called similar, if their decimal notations can be obtained from each other by permuting the digits.

How many numbers from the segment [l, r] have exactly one similar number in that segment?

Input

Contains two integer numbers l and r (1lr1015).

Output

Print the required amount.

Time limit 2 seconds
Memory limit 256 MiB
Input example #1
10 99
Output example #1
72
Author Peter Mitrichev
Source Winter School, Kharkov, 2011, Day 8