407441: GYM102791 G Parking Spaces

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Parking Spacestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Monocarp has opened his own car park. There are $$$n$$$ parking spaces in total, located from left to right. Monocarp decided to number all his parking spaces, but since he really doesn't like the digit $$$k$$$, the numbering would be peculiar.

Monocarp will number the parking spaces one by one (starting from the leftmost) with integers starting from one. If the next number that Monocarp wants to use for the current parking space contains the digit $$$k$$$ in its notation, then Monocarp will skip this number and move on to the next number until he finds a number that does not contain the digit $$$k$$$ in its notation. This would be the number that Monocarp will use for the current parking space; then he will continue assigning numbers to the next parking spaces.

For example, if Monocarp doesn't like the digit $$$1$$$ and there are $$$12$$$ spaces in his car park, they will be numbered as follows: $$$[2, 3, 4, 5, 6, 7, 8, 9, 20, 22, 23, 24]$$$.

Your task is to find the number that Monocarp will assign to the last (i. e. $$$n$$$-th) parking space.

Input

The first line contains two integers $$$n$$$ and $$$k$$$ $$$(1 \le n \le 10^{9}, 0 \le k \le 9)$$$ — the number of parking spaces and the digit that Monocarp doesn't like.

Output

Print the number that Vasily will assign to the $$$n$$$-th parking space.

ExamplesInput
12 1
Output
24
Input
12 2
Output
14
Input
18 0
Output
19
Input
1000000000 5
Output
2620708101
Note

The first example is described in the statement.

In the second example, there are $$$12$$$ parking spaces, and the digit that Monocarp doesn't like is $$$2$$$. The parking space numbers will thus look like this: $$$[1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14]$$$. Therefore, the $$$12$$$-th parking space will have the number $$$14$$$.

In the third example, there are $$$18$$$ parking spaces, and the digit that Monocarp doesn't like is $$$0$$$. The parking space numbers will thus look like this: $$$[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19]$$$. Therefore, the $$$18$$$-th parking space will have the number $$$19$$$.

加入题单

算法标签: