print max(int(j) for i in range(9000,10000) for j in [str(i)+str(i*2)] if "0" not in j and len(set(j))==9)