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
# Programa para saber de ese anio que año tiene todos los digitos diferentes

# Modulo para verificar si ese año es diferente
def DigitosDiferentes(Anio):
    A = Anio//1000
    B = (Anio%1000)//100
    C = (Anio%100)//10
    D = Anio%10
    L = []
    L.append(A)
    L.append(B)
    L.append(C)
    L.append(D)
    L.sort()
    return((int(L[0]))!=(int(L[1]))!=(int(L[2]))!=(int(L[3])))
# Modulo para devolver el año mayor al año entregado con diferentes digitos
def SiguienteAnioDiferente(Anio):
    i=Anio
    while(i>0):
        i+=1
        if(DigitosDiferentes(i)):
            break
    return i
# Programa Principal
Anio = input()
A = int(Anio)
print(SiguienteAnioDiferente(A))
