#include #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; typedef unsigned long long ull; template bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n = s.size(); int mx = 0; int mi = -1; for(int i = n - 1; i >= 0; i--){ if(chmax(mx, s[i] - '0')) mi = i; } int j = 0; while(j < n && s[j] - '0' == mx) j++; swap(s[j], s[mi]); cout << s << endl; }