The new head of the organization discovered that his predecessor, for reasons known only to him, did not use certain digits in the numbering of official documents—specifically, numbers whose decimal representation contained some excluded digits. In different years, different sets of digits could be rejected.
Each year, the initial number chosen by the previous director was the smallest non-negative integer that did not contain any of the rejected digits for that year.
For each subsequent document, whenever the next number contained a rejected digit, it was simply skipped. This was repeated until the next number did not contain any unwanted digits. For example, if the rejected digits were 8, 7, 9, 5, 1, then the first few documents in that year received the numbers: 0, 2, 3, 4, 6, 20, 22, 23, 24, 26, 30, 32, 33,
Since the predecessor led the organization for a long time and there accumulated many numbered documents, the new leader needs a program that, given a set of rejected digits and the ordinal number of a document (counted from zero), can quickly determine the official number assigned to that document.
The input file contains two non-empty lines. The first line lists, separated by spaces, the rejected digits (from one to eight in total, inclusive). The second line contains the serial number of the desired document.
The total number of rejected digits is not less than and not more than .
The serial number of the required document is not less than and does not exceed 1\,000\,000\,000.
The output file contains a single number: the number of the requested document, i.e., the official document number for the specified serial number.
Example 1