#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
using namespace std;
string s;
long n;
long N10;
int used[10];
long ans,ansm=-1;
void f(int i,long a)
{
	if(i==s.size())
	{
		if(ansm<min(abs(n-a),N10-abs(n-a)))
			ansm=min(abs(n-a),N10-abs(n-a)),ans=a;
	}
	else
	{
		for(int j=0;j<10;j++)
		{
			if(used[j])continue;
			used[j]=1;
			f(i+1,a*10+j);
			used[j]=0;
		}
	}
}
int main()
{
	cin>>s;
	n=stol(s);
	N10=1;
	for(int i=0;i<s.size();i++)N10*=10;
	f(0,0);
	cout<<setfill('0')<<setw(s.size())<<ans<<endl;
}


### Prompt

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

Example

Input

201


Output

701

### Response

```cpp
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
using namespace std;
string s;
long n;
long N10;
int used[10];
long ans,ansm=-1;
void f(int i,long a)
{
	if(i==s.size())
	{
		if(ansm<min(abs(n-a),N10-abs(n-a)))
			ansm=min(abs(n-a),N10-abs(n-a)),ans=a;
	}
	else
	{
		for(int j=0;j<10;j++)
		{
			if(used[j])continue;
			used[j]=1;
			f(i+1,a*10+j);
			used[j]=0;
		}
	}
}
int main()
{
	cin>>s;
	n=stol(s);
	N10=1;
	for(int i=0;i<s.size();i++)N10*=10;
	f(0,0);
	cout<<setfill('0')<<setw(s.size())<<ans<<endl;
}


```