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 BS
{
	public static void main(String[] ar)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String[] s = br.readLine().split(" ");
		//int len = Integer.parseInt(s[0]);
		//int n = Integer.parseInt(s[1]);
		//String str = br.readLine();
		//String str_rev = br.readLine(),str_rev_rev="";
		//char[] c = str.toCharArray();
		//int c=0,c1=0;
		int n = Integer.parseInt(br.readLine())+1;
		//int[] a = new int[3];
		while(check_rep_digits(n))
		{
			n+=1;
			//String[] s = br.readLine().split(" ");
				//if(s.charAt(i)=='7'||s.charAt(i)=='4')
				//c++;
			//a[1]+=Integer.parseInt(s[1]);
			//a[2]+=Integer.parseInt(s[2]);
		}
		//String str = String.valueOf(c);	
		/**for(int i=0;i<str.length();i++)
			if(str.charAt(i)=='7'||str.charAt(i)=='4')
				c1++;
		if((str.length()-c1)==0)
			System.out.println("YES");
		else**/
			System.out.println(n);
		/**for(int i=str_rev.length()-1;i>=0;i--)
			str_rev_rev+=Character.toString(str_rev.charAt(i));
		if(str_rev_rev.equals(str))
			System.out.println("YES");
		else
			System.out.println("NO");
		for(int i=0;i<26;i++)
			if(a[i]>0)
				c++;
			//System.out.println(c);
		if(c%2==0)
			System.out.println("CHAT WITH HER!");
		else
			System.out.println("IGNORE HIM!");**/
	}
	public static boolean check_rep_digits(int n)
	{
		String s = String.valueOf(n);
		for(int i=0;i<4;i++)
			for(int j=i+1;j<4;j++)
				if(s.charAt(i)==s.charAt(j))
					return true;
		return false;		
	}
}
