#include <bits/stdc++.h>

using namespace std;

typedef long long int64;

int main()
{
  string S;
  cin >> S;

  int64 val = stoll(S);
  int64 power = 1;
  for(int i = 0; i < S.size(); i++) power *= 10;
  vector< int > vv(10);
  iota(begin(vv), end(vv), 0);

  pair< int64, int64 > ret(1LL << 59, -1);
  do {
    int64 v = 0;
    for(int i = 0; i < S.size(); i++) v = v * 10 + vv[i];
    ret = min(ret, {-min(power - llabs(v - val), llabs(v - val)), v});
  } while(next_permutation(begin(vv), end(vv)));

  printf("%0*lld\n", S.size(), ret.second);
}
### Prompt

Your challenge is to write a cpp solution to the following problem:

Example

Input

201


Output

701

### Response

```cpp
#include <bits/stdc++.h>

using namespace std;

typedef long long int64;

int main()
{
  string S;
  cin >> S;

  int64 val = stoll(S);
  int64 power = 1;
  for(int i = 0; i < S.size(); i++) power *= 10;
  vector< int > vv(10);
  iota(begin(vv), end(vv), 0);

  pair< int64, int64 > ret(1LL << 59, -1);
  do {
    int64 v = 0;
    for(int i = 0; i < S.size(); i++) v = v * 10 + vv[i];
    ret = min(ret, {-min(power - llabs(v - val), llabs(v - val)), v});
  } while(next_permutation(begin(vv), end(vv)));

  printf("%0*lld\n", S.size(), ret.second);
}
```