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.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;

public class Solution {
public static void main(String []args)
{
    Scanner scan =new Scanner(System.in);
    int s1=scan.nextInt();
    int x=s1+1,b=0;
    String str=new String();
    int []ch=new int[10];
    //System.out.println(Arrays.toString(ch));
    while(true)
    {
        b=0;
        str=String.valueOf(x);
        //System.out.println(String.valueOf(x));
        for(int i=0;i<4;i++)
        {
            ch[str.charAt(i)-'0']++;
        }
        //System.out.println(Arrays.toString(ch));
        for(int i=0;i<10;i++)
        {
            if(ch[i]>1)
            {
                b=1;
                break;
            }
        }
         if(b==0)
         {
         System.out.println(x);
         return ;
         }
         else
         {
         Arrays.fill(ch,0);
         //System.out.println(" : "+Arrays.toString(ch));
         x++;
         }
         
    }
}
       
}


