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.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
    public static void main(String args[]) throws Exception{
        FastReader fr = new FastReader();
        int year = fr.nextInt(), next;
        next = year + 1;
        while(true){
        	if(isDistinct(next + "")){
        		break;
        	}
        	else{
        		next++;
        	}
        }
        System.out.println(next);
    }

    private static boolean isDistinct(String year){
    	for(int i = 0; i < year.length() - 1; i++){
    		for(int j = i + 1; j < year.length(); j++){
    			if(year.charAt(i) == year.charAt(j)){
    				return false;
    			}
    		}
    	}
    	return true;
    }
}

class FastReader{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;
    private boolean usedNext;

    public FastReader(){
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
        usedNext = false;
    }

    public FastReader(String file_name) throws IOException{
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
        usedNext = false;
    }

    public String readLine() throws IOException{
    	if(usedNext){
    		usedNext = false;
    		readLine();
    	}
        byte[] buf = new byte[110];
        int cnt = 0, c;
        while((c = read()) != -1){
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt).trim();
    }

    public int nextInt() throws IOException{
    	usedNext = true;
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if(neg)
            c = read();
        do{
        	ret = ret * 10 + c - '0';
        }while((c = read()) >= '0' && c <= '9');
        if(neg)
        	return -ret;
        return ret;
    }

    public long nextLong() throws IOException{
    	usedNext = true;
        long ret = 0;
        byte c = read();
        while(c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if(neg)
            c = read();
        do{
            ret = ret * 10 + c - '0';
        }
        while((c = read()) >= '0' && c <= '9');
        if(neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException{
    	usedNext = true;
        double ret = 0, div = 1;
        byte c = read();
        while(c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if(neg)
            c = read();
        do{
            ret = ret * 10 + c - '0';
        }
        while((c = read()) >= '0' && c <= '9');
        if(c == '.'){
            while ((c = read()) >= '0' && c <= '9'){
                ret += (c - '0') / (div *= 10);
            }
        }
        if(neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException{
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if(bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException{
        if(bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException{
        if(din == null)
            return;
        din.close();
    }
}