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

/**
 * Write a description of class uniqueDigits here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
import java.util.NavigableSet;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.Map;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;
import java.util.AbstractMap;
import java.util.NoSuchElementException;
import java.util.TreeSet;
import java.math.BigInteger;
import java.io.InputStream;
import java.io.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	   // System.out.println("hh");
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		
	//	OutputWriter out = new OutputWriter(outputStream);
		//int count = in.readInt();
//		out.printLine(dig(num));
//		out.close();
        System.out.println(dig(num));
	}

    public static int dig(int x) {
        if(uni(String.valueOf(x+1)))
            return x+1;
        return dig(x+1);
       
    }
    
    public static boolean uni(String x) {
        for(int i=0;i<x.length();i++) {
            if(x.indexOf(x.charAt(i), i+1) > 0)
                return false;               
        }
        return true;
    }

}
