#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long

int hoge=1;

int calc(int a,int b){
  return min(abs(a-b),hoge-abs(a-b));
}

signed main(){
  string a;
  cin >> a;
  
  int n = 0;
  for (int i = 0; i < a.size(); ++i) {
    n = 10 * n + (a[i] - '0');
  }
  // cin>>n;
  int kt=a.size();
  lp(i,kt)hoge*=10;
  vector<int> v({0,1,2,3,4,5,6,7,8,9});
  int ans;
  int maxdst=-1;
  string ansd = "";
  do{
    int x=0;
    string res = "";
    lp(i,kt){
      res = res+char(v[i] + '0');
      x*=10;
      x+=v[i];
    }

    if (maxdst < calc(n, x)) {
      ansd = res;
      ans = x;
      maxdst = calc(n, x);
    }
  }
  while(next_permutation(v.begin(),v.end()));
  //string ansd=string(kt-to_string(ans).size(),'0')+to_string(ans);
  cout<<ansd<<endl;
  return 0; 
}


### Prompt

Please create a solution in cpp to the following problem:

Example

Input

201


Output

701

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long

int hoge=1;

int calc(int a,int b){
  return min(abs(a-b),hoge-abs(a-b));
}

signed main(){
  string a;
  cin >> a;
  
  int n = 0;
  for (int i = 0; i < a.size(); ++i) {
    n = 10 * n + (a[i] - '0');
  }
  // cin>>n;
  int kt=a.size();
  lp(i,kt)hoge*=10;
  vector<int> v({0,1,2,3,4,5,6,7,8,9});
  int ans;
  int maxdst=-1;
  string ansd = "";
  do{
    int x=0;
    string res = "";
    lp(i,kt){
      res = res+char(v[i] + '0');
      x*=10;
      x+=v[i];
    }

    if (maxdst < calc(n, x)) {
      ansd = res;
      ans = x;
      maxdst = calc(n, x);
    }
  }
  while(next_permutation(v.begin(),v.end()));
  //string ansd=string(kt-to_string(ans).size(),'0')+to_string(ans);
  cout<<ansd<<endl;
  return 0; 
}


```