题目描述
Problem Description
Consider the set of positive integers from $1$ to $N$. Let's arrange the elements of this set in lexicographical order, for example, when $N=11$, the order should be: $1, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9$.
Define the position of $K$ among the $N$ numbers as $Q(N,K)$, for example, $Q(11,2)=4$. Given integers $K$ and $M$, find the smallest $N$ such that $Q(N,K)=M$.
Input Format
The input file contains a single line with two integers $K$ and $M$.
Output Format
The output file contains a single line with the smallest $N$. If no such $N$ exists, output $0$.
Sample Input and Output
Sample Input #1
2 4
Sample Output #1
11
Sample Input #2
100000001 1000000000
Sample Output #2
100000000888888879
Notes
Data Specification
- $40\%$ of the test cases have $1 \le K, M \le 10^5$.
- $100\%$ of the test cases have $1 \le K, M \le 10^9$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分
样例输入
2 4
样例输出
11