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
/**
 * Created by Kirill Antonov on 15.10.2015.
 */
import java.util.Scanner;

public class test1 {
    public static int a[] = new int [4];
    public static boolean check(){
        for (int i =0; i<3; i++){
            for (int j = i+1; j<4; j++){
                if (a[i] == a[j]){
                    return false;
                }
            }
        }
        return true;
    }
    public static void increase(){
        a[3]++;
        for (int i = 3; i>0; i--){
            a[i-1] += a[i]/10;
            a[i] = a[i]%10;
        }
    }
    public static void main(String[] args) throws Exception{
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        for (int i = 0; i<4; i++){
            int power = 3-i;
            int devider = 1;
            for (int j = 0; j<power; j++){
                devider *= 10;
            }
            a[i] = (k/devider)%10;
        }
        //for (int i= 0; i<4; i++) a[i] = i*2 + 1;
        increase();
        while (!check()){
            increase();
        }
        for (int i = 0; i<4; i++){
            System.out.print(a[i]);
        }
    }
}
