#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll s, ten, ma = 0;
int n;
VI ans;

ll diff(VI a){
    ll x = 0;
    REP(i,n) x = 10 * x + a[i];
    return min(abs(s-x), ten-abs(s-x));
}

void dfs(int i, VI a, VI used){
    if (i == n){
        if (diff(a) > ma){
            ans = a;
            ma = diff(a);
        }
        return;
    }
    REP(j,10){
        if (used[j]) continue;
        a[i] = j;
        used[j] = 1;
        dfs(i+1, a, used);
        used[j] = 0;
    }
}

int main() {
    string t;
    cin >> t;
    n = t.length();
    s = 0;
    REP(i,n) s = 10*s + t[i]-'0';
    ten = 1;
    REP(i,n) ten *= 10;

    ans.resize(n);
    VI a(n), used(10);

    dfs(0, a, used);

    REP(i,n) cout << ans[i];
    cout << 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 <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

ll s, ten, ma = 0;
int n;
VI ans;

ll diff(VI a){
    ll x = 0;
    REP(i,n) x = 10 * x + a[i];
    return min(abs(s-x), ten-abs(s-x));
}

void dfs(int i, VI a, VI used){
    if (i == n){
        if (diff(a) > ma){
            ans = a;
            ma = diff(a);
        }
        return;
    }
    REP(j,10){
        if (used[j]) continue;
        a[i] = j;
        used[j] = 1;
        dfs(i+1, a, used);
        used[j] = 0;
    }
}

int main() {
    string t;
    cin >> t;
    n = t.length();
    s = 0;
    REP(i,n) s = 10*s + t[i]-'0';
    ten = 1;
    REP(i,n) ten *= 10;

    ans.resize(n);
    VI a(n), used(10);

    dfs(0, a, used);

    REP(i,n) cout << ans[i];
    cout << endl;

    return 0;
}
```