#include "bits/stdc++.h"
using namespace std;
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2728
/*
?????°???????????????????????¨??????????????????????¬???§??????????????????5sec?????????
*/
typedef long long ll;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string s; cin >> s;
	ll N = stoll(s);
	int digit = s.length();
	ll Ten = 1;
	for (int i = 0; i < digit;i++) Ten *= 10;
	vector<int> v(10);
	iota(v.begin(), v.end(), 0);
	ll ans = -1;
	ll pre = -1;
	do {
		ll now = 0;
		for (int i = 0; i < digit;i++) now = now * 10 + v[i];
		ll diff = min(abs(N - now), Ten - abs(N - now));
		if (diff > pre) {
			pre = diff;
			ans = now;
		}
	} while (next_permutation(v.begin(), v.end()));
	cout << setfill('0') << setw(digit) << right << ans << endl;
}
### Prompt

Please provide a CPP coded solution to the problem described below:

Example

Input

201


Output

701

### Response

```cpp
#include "bits/stdc++.h"
using namespace std;
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2728
/*
?????°???????????????????????¨??????????????????????¬???§??????????????????5sec?????????
*/
typedef long long ll;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string s; cin >> s;
	ll N = stoll(s);
	int digit = s.length();
	ll Ten = 1;
	for (int i = 0; i < digit;i++) Ten *= 10;
	vector<int> v(10);
	iota(v.begin(), v.end(), 0);
	ll ans = -1;
	ll pre = -1;
	do {
		ll now = 0;
		for (int i = 0; i < digit;i++) now = now * 10 + v[i];
		ll diff = min(abs(N - now), Ten - abs(N - now));
		if (diff > pre) {
			pre = diff;
			ans = now;
		}
	} while (next_permutation(v.begin(), v.end()));
	cout << setfill('0') << setw(digit) << right << ans << endl;
}
```