#K37412. Remove Digit

    ID: 25971 Type: Default 1000ms 256MiB

Remove Digit

Remove Digit

Given an integer (M) and a single-digit integer (X), find the smallest integer greater than (M) that does not contain the digit (X) in its decimal representation.

For example, if (M = 28) and (X = 2), the answer is (30) because (29) contains the digit (2), whereas (30) does not. This problem requires careful string manipulation and a brute-force search.

inputFormat

The input consists of two integers (M) and (X) separated by a space. (M) is the starting integer and (X) is the digit that must not appear in the answer.

outputFormat

Output the smallest integer greater than (M) that does not contain the digit (X) in its decimal representation.## sample

28 2
30