It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.

Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has only distinct digits.

Input

The single line contains integer y (1000 ≤ y ≤ 9000) — the year number.

Output

Print a single integer — the minimum year number that is strictly larger than y and all it's digits are distinct. It is guaranteed that the answer exists.

Examples

Input

1987


Output

2013


Input

2013


Output

2014
import java.io.*;
import java.util.*;


public class CodeForce {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	n++;

	while (true) {
		int k = n;
		int d1 = k%10;
		k = k/10;
		int d2 = k%10;
		k = k/10;
		int d3 = k % 10;
		k = k/10;
		int d4 = k % 10;

		if (d1 != d2 && d1 != d3 && d1 != d4 && d2 != d3 && d2 != d4 && d3 != d4) {
			System.out.println(n);
			break;
		}

		n++;
	}



	// long d = sc.nextLong();
	// if (k==1 || l==1 || m==1 || n==1) {
	// 	System.out.println(d);
	// 	return;
	// }
	// long count = 0;
	// for (long i = 1; i<=d; i++) {
	// 	if (i%k == 0 || i%l ==0 || i%m ==0 || i%n == 0)
	// 		count++;
	// }
	// System.out.println(count);

	// String temp = "";	
	// while(t!=0) {
	// 	temp = "";
	// 	for (int i = 0; i < str1.length(); ) {
	// 		if (i == (str1.length() - 1)) {
	// 			temp += str1.charAt(i);
	// 			i++;
	// 		} else {
	// 			if((str1.substring(i, i+2)).compareTo("BG") == 0) {
	// 				temp += "GB";
	// 				i+=2;
	// 			} else {
	// 				temp+= str1.charAt(i);
	// 				i+=1;
	// 			}
	// 		}
	// 	}
	// 	str1 = temp;
	// 	t--;
	// }

	// 	System.out.println("NO");


	}
}