#include<iostream>
#include<string>
#include<vector>

using namespace std;
#define int long long

const int inf = 1e18;

string t;
int num, ten;
int ans;
vector<int> used(10);
int N;

void solve(int depth, string n, int m) {

    //cout<<depth<<" "<<n<<" "<<m<<" ans = "<<ans<<" ten = "<<ten<<endl;
    
    if(depth == N) {
// cout<<"[][]"<<endl;
        // cout<<min(abs(ans - num), abs(ten - abs(ans - num)))<<" <>  "<< min(abs(m - num), abs(ten - abs(m - num)))<<endl;
        if(min(abs(ans - num), abs(ten - abs(ans - num))) < min(abs(m - num), abs(ten - abs(m - num)))) {
            ans = m;
            t = n;
        } else if(min(abs(ans - num), abs(ten - abs(ans - num))) == min(abs(m - num), abs(ten - abs(m - num)))){
            if(ans > m) {
                ans = m;
                t = n;
            }
        }

        return ;
    }

    for(int i = 0; i < used.size(); i++){
        if(used[i]) continue;
        
        used[i] = true;

        n[depth] = '0' + i;
        
        m = m * 10 + i;

        solve(depth+1, n, m);

        m /= 10;
        
        used[i] = false;
    }
}

int my_stoi(string s){
    int res = 0;

    for(int i = 0; i < s.size(); i++){
        res = res * 10 + s[i] - '0';
    }

    return res;
}
     
signed main(){

    string s, hoge;

    cin>>s;

    num = my_stoi(s);
    ans = num;

    N = s.size();

    ten = 1;

    for(int i = 0; i < N; i++) ten *= 10;

    //cout<<"<><>"<<endl;
    hoge.resize(N, '0');
   

    solve(0, hoge, 0);
    
    cout<<t<<endl;
    
    return 0;
}


### Prompt

Your task is to create a cpp solution to the following problem:

Example

Input

201


Output

701

### Response

```cpp
#include<iostream>
#include<string>
#include<vector>

using namespace std;
#define int long long

const int inf = 1e18;

string t;
int num, ten;
int ans;
vector<int> used(10);
int N;

void solve(int depth, string n, int m) {

    //cout<<depth<<" "<<n<<" "<<m<<" ans = "<<ans<<" ten = "<<ten<<endl;
    
    if(depth == N) {
// cout<<"[][]"<<endl;
        // cout<<min(abs(ans - num), abs(ten - abs(ans - num)))<<" <>  "<< min(abs(m - num), abs(ten - abs(m - num)))<<endl;
        if(min(abs(ans - num), abs(ten - abs(ans - num))) < min(abs(m - num), abs(ten - abs(m - num)))) {
            ans = m;
            t = n;
        } else if(min(abs(ans - num), abs(ten - abs(ans - num))) == min(abs(m - num), abs(ten - abs(m - num)))){
            if(ans > m) {
                ans = m;
                t = n;
            }
        }

        return ;
    }

    for(int i = 0; i < used.size(); i++){
        if(used[i]) continue;
        
        used[i] = true;

        n[depth] = '0' + i;
        
        m = m * 10 + i;

        solve(depth+1, n, m);

        m /= 10;
        
        used[i] = false;
    }
}

int my_stoi(string s){
    int res = 0;

    for(int i = 0; i < s.size(); i++){
        res = res * 10 + s[i] - '0';
    }

    return res;
}
     
signed main(){

    string s, hoge;

    cin>>s;

    num = my_stoi(s);
    ans = num;

    N = s.size();

    ten = 1;

    for(int i = 0; i < N; i++) ten *= 10;

    //cout<<"<><>"<<endl;
    hoge.resize(N, '0');
   

    solve(0, hoge, 0);
    
    cout<<t<<endl;
    
    return 0;
}


```