K-digit number High#2867

K-digit number High

1 second
8 megabytes
Hard

A number is called a -digit number if the number of distinct digits in its decimal representation (ignoring leading zeros) does not exceed .

Given a number , find the -digit number closest to .

Input

The input consists of a single line containing two integers and without leading zeros (1 \leq K \leq 10, 0 \leq x \leq 10^6).

Output

Output a -digit number such that |y-x| is minimized. If there are multiple such numbers, you may output any of them.

Examples

Example 1

Loading
Loading