#C3641. Closest Perfect Number

    ID: 47091 Type: Default 1000ms 256MiB

Closest Perfect Number

Closest Perfect Number

Given three integers N, D, and X, your task is to find the smallest integer greater than or equal to N that contains the digit D at least X times in its decimal representation.

The constraints are given by the following inequalities in \(\LaTeX\) format:

  • \(1 \leq N \leq 10^{7}\)
  • \(0 \leq D \leq 9\)
  • \(1 \leq X \leq 7\)

For example, if the input is 100 1 2 then the answer is 101 because 101 is the smallest number greater than or equal to 100 that contains the digit 1 at least two times.

inputFormat

The input is provided via standard input. It consists of a single line with three space-separated integers: N, D, and X.

For example: 100 1 2

outputFormat

Output the smallest integer greater than or equal to N that contains the digit D at least X times. The output should be printed to standard output.

## sample
100 1 2
101