// Copyright: lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

ll read(){
    ll x=0,f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

ll num;

inline void work() {
    char s[11];
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    rep(i, 1, len) num = num * 10 + s[i] - '0';
    int a[11], b[11];
    rep(i, 0, 9) a[i] = i;
    ll ans = -1;
    ll xx = 1;
    rep(i, 1, len) xx = xx * 10;
    do {
        ll nw = 0;
        rep(i, 0, len - 1) nw = nw * 10 + a[i];
        ll tmp = min(abs(num - nw), xx - abs(num - nw));
        if (ans < tmp) {
            ans = tmp;
            rep(i, 0, len - 1) b[i] = a[i];
        }
    } while (next_permutation(a, a + 10));
    rep(i, 0, len - 1) cout<<b[i]; cout<<endl;
}

int main(){
    #ifdef LZT
        freopen("in","r",stdin);
    #endif

    work();

    #ifdef LZT
        Debug("My Time: %.3lf s\n", (double)clock() / CLOCKS_PER_SEC);
    #endif
}


### Prompt

Construct a CPP code solution to the problem outlined:

Example

Input

201


Output

701

### Response

```cpp
// Copyright: lzt
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<iostream>
#include<queue>
#include<string>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,j,k)  for(register int i=(int)(j);i<=(int)(k);i++)
#define rrep(i,j,k) for(register int i=(int)(j);i>=(int)(k);i--)
#define Debug(...) fprintf(stderr, __VA_ARGS__)

ll read(){
    ll x=0,f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

ll num;

inline void work() {
    char s[11];
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    rep(i, 1, len) num = num * 10 + s[i] - '0';
    int a[11], b[11];
    rep(i, 0, 9) a[i] = i;
    ll ans = -1;
    ll xx = 1;
    rep(i, 1, len) xx = xx * 10;
    do {
        ll nw = 0;
        rep(i, 0, len - 1) nw = nw * 10 + a[i];
        ll tmp = min(abs(num - nw), xx - abs(num - nw));
        if (ans < tmp) {
            ans = tmp;
            rep(i, 0, len - 1) b[i] = a[i];
        }
    } while (next_permutation(a, a + 10));
    rep(i, 0, len - 1) cout<<b[i]; cout<<endl;
}

int main(){
    #ifdef LZT
        freopen("in","r",stdin);
    #endif

    work();

    #ifdef LZT
        Debug("My Time: %.3lf s\n", (double)clock() / CLOCKS_PER_SEC);
    #endif
}


```