Provenance: English mirror of the original statement: https://ac.nowcoder.com/acm/problem/25075
Archive cross-check: work/usaco_2007/open07/archive/analysis/analysis/OPEN07.count.htm and
work/usaco_2007/open07/archive/testdata/count.1.in / .out.
Farmer John wants to label his $N$ cows, but cows do not like having the digit $L$ written on them, so he avoids that digit.
The cows receive the smallest set of $N$ positive integers whose decimal representations do not contain digit $L$. What is the largest label Farmer John must write?
Input
Line 1 contains two space-separated integers $N$ and $L$, where $1 \le N \le 1{,}000{,}000$ and $0 \le L \le 9$.
Output
Print one integer: the largest number Farmer John has to write on any cow.
Examples
Input 1
10 1
Output 1
22
The first ten positive integers without digit 1 are
2, 3, 4, 5, 6, 7, 8, 9, 20, 22.