public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st = new StringTokenizer(br.readLine());
String num = st.nextToken();
int len = num.length();
int[] nums = new int[len];
for(int i = 0; i < len; i++) {
nums[i] = num.charAt(i) - '0';
}
int idx = 0;
int n = 0;
while(idx < len) {
n++;
int temp = n;
int length = (int)(Math.log10(n) + 1);
int[] arr = new int[length];
for(int i = length - 1; i >= 0; i--) {
arr[i] = temp % 10;
temp /= 10;
}
for(int i = 0; i < length; i++) {
if(nums[idx] == arr[i])
idx++;
if(idx >= len)
break;
}
}
bw.write(n + "");
bw.close();
}
출처:https://www.acmicpc.net/problem/1515