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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class vac {
	
	static boolean check(int n){
		String f = Integer.toString(n);
		if(f.charAt(0)!=f.charAt(1)&& f.charAt(0)!= f.charAt(2) && f.charAt(0)!= f.charAt(3)&& f.charAt(1)!= f.charAt(2) && f.charAt(1)!= f.charAt(3) && f.charAt(2)!= f.charAt(3)){
			return true;
		}
		else {
			return false;
		}
		
		
	}
	public static void main(String[] args) throws IOException{
		
		
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int f = 0;
		while(f==0) {
			n++;
			if(check(n)) {
				f=1;
				break;
			}
			else {
				continue;
			}
		}
		System.out.println(n);
		
		
//		Reader.init(System.in);
//		int t = Reader.nextInt();
//		for(int i = 0;i<t;i++) {
//			int n = Reader.nextInt();
//			String s = Reader.next();
//			StringBuilder s8 = new StringBuilder(s);
//			TreeSet<String>  ts = new TreeSet<String>();
//			
//			for(int k = 1;k<=n;k++) {
//				int j = 0;
//				StringBuilder s1 = s8;
//				
//					String s3 = s1.substring(0,j);
//					String s4 = s1.substring(j+k,n);
////					System.out.println(s3);
////					System.out.println(s4);
//					
//				
//					
//					
//					
//				
//					StringBuilder s2 = new StringBuilder(s1.substring(j,j+k));
//					
//					s2.reverse();
//					String e3 =s2.toString();
////					System.out.println(e3);
//					String g = s3+e3+s4;
//					
//					StringBuilder q1 =new StringBuilder(g);
////					System.out.println(g);
//					s1 = q1;
//				
//					
//					
//					
//				
//				
//				String w = s1.toString()+k;
//				ts.add(w);
//			}
//			System.out.println(ts);
//
//		String z = ts.first();
//	
//		System.out.println(z.substring(0,n));
//		System.out.println(z.substring(n,z.length()));
//			
//			
//			
//		}
//		
//		
//		
//		
		}
	
		
//		Reader.init(System.in);
//		TreeSet<String> str = new TreeSet<String>(); 
//		
//			
//		int n = Reader.nextInt();
//		int m = Reader.nextInt();
//		String s1[] = new String[n];
//		
//		for(int j = 0;j<n;j++) {
//			String s = Reader.next();
//			str.add(s);
//			s1[j]=s;
//			
//		}
//		TreeSet<String> str2 = new TreeSet<String>(); 
//		
//		
//		for(int j = 0;j<n;j++)
//		{		
//			
//			StringBuilder a = new StringBuilder(s1[j]);
//			a.reverse();
//			String w = a.toString();
//			if(str.contains(w)&& !w.equals(s1[j])) {
//				StringBuilder a1 = new StringBuilder(s1[j]+w);
//				a1.reverse();
//				String f = a1.toString();
//				if(!str2.contains(w+s1[j])) {
//					str2.add(s1[j]+w);
//				}
//				}
//			}
//		
//		String a4 ="";
//		for(int j = 0;j<n;j++)
//		{		
//			
//			StringBuilder a = new StringBuilder(s1[j]);
//			a.reverse();
//			String d = a.toString();
//			if(d.equals(s1[j])) {
//				a4=s1[j];
//				break;
//				
//				
//			}
//				
//			}
//		String new1 = "";
//			
//		Iterator <String> it = str2.iterator();
//		while(it.hasNext()) {
//			new1+= it.next().substring(0,m);
//			
//		}
//		String new2 = "";
//		
//		Iterator <String> it2 = str2.descendingIterator();
//		while(it2.hasNext()) {
//			new2+= it2.next().substring(m,2*m);
//			
//		}
//		System.out.println((new1+a4+new2).length());
//		
//		System.out.println(new1+a4+new2);
		
		
		
		
		
		
				
				
	
			
			
		
		
			
			  
			
				
			
			
			
			
			
			
			
			
			
		
//			
			
		
			
		
}
	    


	


class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

   
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

 
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
     
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
	
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}

	