#include #define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false)) using namespace std; int main() { fastIO; string src; cin >> src; size_t maxv = 0; for (const auto ch : src) { maxv = max(maxv, (size_t)(ch - '0')); } vector idxs; for (size_t i = 0; i < src.size(); ++i) { if (maxv == (size_t)(src[i] - '0')) { idxs.emplace_back(i); } } vector res; for (const auto idx : idxs) { string dst = src; char temp = dst[idx]; dst[idx] = dst[0]; dst[0] = temp; res.emplace_back(stoi(dst)); } sort(res.begin(), res.end()); cout << res.back() << '\n'; return 0; }