n = list(input()) ans = 0 for i in range(len(n)): for j in range(len(n)): n[i], n[j] = n[j], n[i] ans = max(ans, int(''.join(n))) n[i], n[j] = n[j], n[i] print(ans)