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
//package codeforces;

import java.util.ArrayList;
import java.util.Scanner;

public class beautifulYear {

	public static void main(String[] args) {
		
		Scanner s = new Scanner(System.in);
		
		int origYear = s.nextInt();
		
		ArrayList<Integer> list = new ArrayList<Integer>();
		
		int tempYear = origYear+1; //start testing with the year after

		int increment = 2; //and the next year to test will be the year after that
		
		while(list.size() != 4) {//if there are 4 elements in list, the year must be beautiful
			
			for(int i = 0; i < 4; i++) {//loop 4 times		
				
				//System.out.println("i = " + i);
				
				if(!list.contains(tempYear%10)) {
										
					list.add(tempYear%10);//add the current digit in the year to the arraylist
					
					tempYear = (tempYear - (tempYear%10) ) / 10; 
					//i.e. 1977 will change to (1997 - (7) ) / 10 --> = 199
					//eventually tempYear will be 0 if tempYear is a beautiful year	
					
					//System.out.println("tempYear is now " + tempYear);
				}
				
				else {
					
					//System.out.print((origYear+increment-1) + " failed");
					
					list.clear();//empty list because current year failed to be beautiful
					
					//System.out.print(", list has been cleared");
					
					tempYear = origYear + increment;//try the next year (i.e. try 1978 because 1977 failed)
					
					//System.out.println(", and now we'll try " + tempYear);
					//System.out.println();
					
					increment++;//so next time we increment origYear by 3, then by 4, etc.
					            //otherwise, we'd be testing the same year over and over!
					
					break; //break out of current iteration of the for loop
						   //we want the next year to be able to loop the full 4 times
					
				}
					
				
			}//end for
			
			/**
			if(tempYear == 0) {
				System.out.println("tempYear equals 0 , it is time to break");
				break;
			}
			*/
			
		}//end while
		int winnerWinnerChickenDinner = origYear + increment - 1; // -1 because line 38 added 1 to increment 
																  //to prepare for testing the next year but
																  //the current year is the actual winner
		System.out.println(winnerWinnerChickenDinner);
		
	}//end main

}
