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 Kross {
    public void solve() 
    {
        int first = nextInt();
        int ch = first + 1;
        while (ecvivolent(ch)) ch++;
        System.out.print(ch);
    }
    public static void main (String[]args){
        new Kross().run();
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    private void run () {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            //br = new BufferedReader(new FileReader("birthday.in"));
            //out = new PrintWriter(new FileWriter("birthday.out"));
            solve();
            br.close();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private int nextInt () {
        return Integer.parseInt(next());
    }

    private String next () {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
                return "END_OF_FILE";
            }
        }
        return st.nextToken();
    }
    boolean ecvivolent (int year)
    {
        int ed = year % 10;
        int dec = (year % 100 - ed) / 10;
        int sotni = (year % 1000 - (dec * 10) - ed) / 100;
        int thousand = year / 1000;
        if (ed != dec && ed != sotni && ed != thousand && sotni != dec && thousand != dec && sotni != thousand)
        {
            return false;
        } else return true;
    }
}