#include #include #include #include using namespace std; using namespace atcoder; using namespace __gnu_pbds; using ll=long long; using ld=long double; using vll=vector; using vvll=vector; using pll=pair; // using mint=modint; // template // using ordered_map=tree,rb_tree_tag,tree_order_statistics_node_update>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N; cin>>N; vll suff,n; while(N>0){ ll r=N%10; n.push_back(r); if(suff.size()>0)suff.push_back(max(suff.back(),r)); else suff.push_back(r); N/=10; } ll m=n.size(),j=-1; for(int i=m-1;i>=0;--i){ if(n[i]