Sort by sum of digits#2551

Sort by sum of digits

1 second
64 megabytes
Very hard

The sum of a number’s digits is associated with some of its properties. In particular, it is easy to determine divisibility by and using the sum of digits. Computer scientists from Bergen decided to investigate natural numbers and the sums of their digits.

It is well known that working with sorted data is easier than with unsorted data. Therefore, the researchers decided to sort natural numbers by the sum of their digits. If several numbers have equal sums of digits, these numbers are arranged in ascending order.

When the scientists sorted the numbers from to , they obtained the sequence: , , , , , , , , , , , , , , , , , , , .

For a small quantity of numbers, the sorting was performed quickly. When the research expanded to a wider range, some difficulties arose. One of them was to find the position of the number in the sorted sequence of the first natural numbers. Your task is to solve this problem.

Write a program to calculate the position of in the sorted sequence of the first natural numbers.

Input

The single line of the input file contains two natural numbers separated by space: and in their decimal notation (1 \le K \le N \le 10^{12}).

Output

Output one natural number: the position of .

Examples

Example 1

Loading
Loading