#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll dp[11][156][22];
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 1;
	while (kkt--) {
		string jupi; cin >> jupi;
		ll n = stoll(jupi);
		ll N = jupi.size();
		ll mx = 1;
		for (int i = 0; i < N; i++) mx *= 10;
		vector<ll> perm(10); for (int i = 0; i < 10; i++) perm[i] = i;
		ll sa = 0;
		ll res = -1;
		do {
			ll t = 0;
			for (int i = 0; i < N; i++) {
				t = t * 10 + perm[i];
			}
			ll tmp = min(llabs(n - t), mx - llabs(n - t));
			if (chmax(sa, tmp)) {
				res = t;
			}else if(sa == tmp && t < res){
				res = t;
			}

		} while (next_permutation(perm.begin(), perm.end()));
		string s;
		for (int i = 0; i < N - to_string(res).size(); i++) s += '0';
		s += to_string(res);
		cout << s << endl;
	}
	return 0;

}


### Prompt

In cpp, your task is to solve the following problem:

Example

Input

201


Output

701

### Response

```cpp
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll dp[11][156][22];
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 1;
	while (kkt--) {
		string jupi; cin >> jupi;
		ll n = stoll(jupi);
		ll N = jupi.size();
		ll mx = 1;
		for (int i = 0; i < N; i++) mx *= 10;
		vector<ll> perm(10); for (int i = 0; i < 10; i++) perm[i] = i;
		ll sa = 0;
		ll res = -1;
		do {
			ll t = 0;
			for (int i = 0; i < N; i++) {
				t = t * 10 + perm[i];
			}
			ll tmp = min(llabs(n - t), mx - llabs(n - t));
			if (chmax(sa, tmp)) {
				res = t;
			}else if(sa == tmp && t < res){
				res = t;
			}

		} while (next_permutation(perm.begin(), perm.end()));
		string s;
		for (int i = 0; i < N - to_string(res).size(); i++) s += '0';
		s += to_string(res);
		cout << s << endl;
	}
	return 0;

}


```