luogu#P6387. [COCI 2007/2008 #4] VECI

[COCI 2007/2008 #4] VECI

Problem Description

Given a positive integer xx, find the smallest integer yy such that the number of occurrences of each digit 00 to 99 in yy is respectively equal to that in xx, and x<yx \lt y.

Input Format

The input contains only one line with an integer xx.

Output Format

Output one line with an integer representing the answer. If such a yy does not exist, output 00.

156

165
330

0
27711

71127

Hint

Constraints

For all testdata, it is guaranteed that 1x<1061 \leq x \lt 10^6.

Notes

Translated from COCI2007-2008 CONTEST #4 T2 VECI.

Translated by ChatGPT 5