cho.sh
Notes
Loading...

Smallest Integer with K Distinct Digits

Time limit

2s

Memory limit

128 MB

Problem

You are given natural numbers N and K. Among all natural numbers greater than or equal to N, find the smallest number that uses exactly K distinct decimal digits.

Input

The first line contains N and K separated by a space.

N is a natural number not greater than 10^18. K is a natural number not greater than 10.

Output

Output the smallest natural number that satisfies the condition.