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 static java.lang.Integer.parseInt;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class BeautifulYear {
    static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
//        String str = in.readLine();
//        int y = parseInt(str)+1;
//        str = y+"";
//        while (true) {
//            if(valid(str)){
//                out.println(str);
//                out.flush();
//                return;
//            }
//             y = parseInt(str);
//            y++;
//            str = y+"";
//        }
        int n = parseInt(in.readLine());
        outer :
        for (int i = n+1;; i++) {
            int x =0;
            for (int j = i; j > 0; j/=10) {
                if(x<<31-j%10 < 0)
                    continue outer;
                x |= 1<<j%10;
            }
            out.println(i);
            out.flush();
            return; 
        }
    }
    static boolean valid(String str){
        if(str.charAt(0) == str.charAt(1) || str.charAt(0) == str.charAt(2) || str.charAt(0) == str.charAt(3) ||
                str.charAt(1) == str.charAt(2) || str.charAt(1) == str.charAt(3) || str.charAt(2) == str.charAt(3))
                return false;
        return true;
    }
}
