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.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.*;


public class Solution {



	/*public static int ispr(int n)
    	{
    	//boolean[] isPrime = new boolean[n+1];
        for (int i = 2; i <= n; i++) {
            Prime[i] = true;
        }

        // mark non-primes <= n using Sieve of Eratosthenes
        for (int factor = 2; factor*factor <= n; factor++) {

            // if factor is prime, then mark multiples of factor as nonprime
            // suffices to consider mutiples factor, factor+1, ...,  n/factor
            if (Prime[factor]) {
                for (int j = factor; factor*j <= n; j++) {
                    Prime[factor*j] = false;
                }
            }	
        }	
        // count primes

        /*int primes = 0;
        for (int i = 2; i <= n; i++) {
            if (isPrime	[i])System.out.println(i);


        }*/
	// System.out.println("The number of primes <= " + n + " is " + primes);
	//return 0;
	// if(isPrime[n]==true)return 1; else return 0;

	//}







	public static long fact(long x)
	{
		if(x==0)return 1;
		else return x*fact(x-1);
	}


	public static long exp(long x, long n, long M)
	{

		if(n==0) return 1;

		else if(n%2==0) return exp((x*x)%M,n/2,M);
		else return (x*exp((x*x)%M,(n-1)/2,M))%M;

	}

	//fi

	static long fib(long n)
	{
		long F[][] = new long[][]{{1,1},{1,0}};
		if (n == 0)
			return 0;
		power(F, n-1);

		return F[0][0];
	}

	static void multiply(long F[][], long M[][])
	{
		long x =  F[0][0]*M[0][0] + F[0][1]*M[1][0];
		long y =  F[0][0]*M[0][1] + F[0][1]*M[1][1];
		long z =  F[1][0]*M[0][0] + F[1][1]*M[1][0];
		long w =  F[1][0]*M[0][1] + F[1][1]*M[1][1];

		F[0][0] = x;
		F[0][1] = y;
		F[1][0] = z;
		F[1][1] = w;
	}

	/* Optimized version of power() in method 4 */
	static void power(long F[][], long n)				
	{
		if( n == 0 || n == 1)
			return;
		long M[][] = new long[][]{{1,1},{1,0}};

		power(F, n/2);
		multiply(F, F);

		if (n%2 != 0)
			multiply(F, M);
	}


	static class Point
	{
		long x,y;

		public Point(long a, long b)
		{
			x=a;
			y=b;
		}




	}




	static class compy implements Comparator<Point>
	{
		public int compare(Point a, Point b)
		{

			if(a.y>b.y)return 1;
			if(a.y<b.y) return -1;
			if(a.x>b.x) return 1;
			if(a.x<b.x) return -1;		
			return 0;
		}
	}


	static class compx implements Comparator<Point>
	{
		public int compare(Point a, Point b)
		{

			if(a.x>b.x)return 1;
			if(a.x<b.x) return -1;
			if(a.y>b.y) return 1;
			if(a.y<b.y) return -1;		
			return 0;
		}
	}


	public static int gcd(int a, int b)
	{
		if(b==0)
			return a;
		else return gcd(b,a%b);
	}

	static  class MyScanner {

		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine(){
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

	static MyScanner sc = new  MyScanner();
	static PrintWriter pw = new PrintWriter(System.out, true);
	
	static class Node
	{
		int id,wt;
		
		public Node(int x, int y)
		{
			id=x; wt=y;
		}
		
	}
	
	
	static class Distance
	{
		int id;
		long dist;
		
		public Distance(long x, int y)
		{
			dist=x; id=y;
			
		}
	}

	static int factor(int x)
	{
		if(x%2==1)return x;
		
		else
			return factor(x/2);
		
	}
	
	static void printPath(int parent[], int j)
	{
	    // Base Case : If j is source
	    if (parent[j]==-1)
	        {pw.print(j+" ");return;}

	    printPath(parent, parent[j]);

	    pw.print(j+" ");
	}
	
	//Main begins here :)
	
	public static void main(String[] args) {

	
	
		int y = sc.nextInt();
		
		for(int i=y+1;i<=Integer.MAX_VALUE;i++)
		{
			int tadd=0;
			int cy  = i;
			HashSet<Integer> set = new HashSet<Integer>();
			while(cy>=1)
			{
				int dg=(cy%10);
				if(!set.contains(dg))
				{
					set.add(dg);
					tadd++;
				}
				cy=cy/10;
			}
		 if(tadd==4)
		 {pw.println(i); break;}
			
			
		}
		
		
		pw.close();
	
	}

} 