#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
string S;long long power[11];
int main(){
	power[0]=1;for(int i=1;i<11;i++)power[i]=power[i-1]*10;
	cin>>S;int a[10]={0,1,2,3,4,5,6,7,8,9};
	long long X=0;string Y="";
	do{
		long long P1=stoll(S);
		long long P2=0;
		for(int i=0;i<S.size();i++){
			P2+=power[i]*a[i];
		}
		long long SA=min(abs(P1-P2),power[S.size()]-abs(P1-P2));
		string G="";for(int i=0;i<S.size();i++){G+=(char)('0'+a[S.size()-1-i]);}
		if(SA>X || (SA==X && Y>G)){X=SA;Y=G;}
	}while(next_permutation(a,a+10));
	cout<<Y<<endl;
	return 0;
}
### Prompt

Your task is to create a cpp solution to the following problem:

Example

Input

201


Output

701

### Response

```cpp
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
string S;long long power[11];
int main(){
	power[0]=1;for(int i=1;i<11;i++)power[i]=power[i-1]*10;
	cin>>S;int a[10]={0,1,2,3,4,5,6,7,8,9};
	long long X=0;string Y="";
	do{
		long long P1=stoll(S);
		long long P2=0;
		for(int i=0;i<S.size();i++){
			P2+=power[i]*a[i];
		}
		long long SA=min(abs(P1-P2),power[S.size()]-abs(P1-P2));
		string G="";for(int i=0;i<S.size();i++){G+=(char)('0'+a[S.size()-1-i]);}
		if(SA>X || (SA==X && Y>G)){X=SA;Y=G;}
	}while(next_permutation(a,a+10));
	cout<<Y<<endl;
	return 0;
}
```