Tianjin University Online Judge
Contests Virtual Contests Problems Submit Runs Status Rank List Forum

2829.   Cow Counting
Time Limit: 1.0 Seconds   Memory Limit: 65536K
Total Runs: 1163   Accepted Runs: 577    Multiple test files



Farmer John wants to label his N (1 ≤ N ≤ 1,000,000) cows, but cows don't like having the digit L (0 ≤ L ≤ 9) written on them, so he avoids that.

If the cows are labeled with the smallest set of N positive integers that don't have the digit L, what is the largest number that Farmer John has to write on any cow?

Input

* Line 1: Two space-separated integers: N and L.

Output

* Line 1: A single integer that is the largest number that Farmer John has to write on any cow.

Sample Input

10 1

Sample Output

22

Input Details

Farmer John has 10 cows he needs to label without using the digit 1.

Output Details

The smallest 10 numbers he can use are: 2, 3, 4, 5, 6, 7, 8, 9, 20, and 22.



Source: USACO Open Competition 2007
Submit   List    Runs   Forum   Statistics

Tianjin University Online Judge v1.3.0
Maintance:Fxz. Developer: SuperHacker, G.D.Retop, Fxz