#include <bits/stdc++.h>
using namespace std;

long long n,d,t,ans,answ=0,tmp;
char str1[15],ch=0;

int main(void) {
	long long a;
	cin>>str1;
	n = strlen(str1);
	t = pow(10,n);
	sscanf(str1,"%lld",&d);
	char str[] = "0123456789";
	do {
		swap(str[n],ch);
		sscanf(str,"%lld",&a);
		if((tmp=min(abs(a-d),t-abs(a-d)) ) > answ)
			answ = tmp,ans=a;
		swap(str[n],ch);
		//cout<<a<<' '<<ch<<endl;
		//cout<<str<<endl<<endl;
	} while(next_permutation(str,str+10));
	if(a == 0) 
		for(int i=1;i<=n;i++)
			putchar('0');
	else {
		a = log(ans)/log(10);
		a++;
		for(int i=a;i<n;i++)
			putchar('0');
		cout<<ans;
	}
	cout<<endl;
	return 0;
}
### 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;

long long n,d,t,ans,answ=0,tmp;
char str1[15],ch=0;

int main(void) {
	long long a;
	cin>>str1;
	n = strlen(str1);
	t = pow(10,n);
	sscanf(str1,"%lld",&d);
	char str[] = "0123456789";
	do {
		swap(str[n],ch);
		sscanf(str,"%lld",&a);
		if((tmp=min(abs(a-d),t-abs(a-d)) ) > answ)
			answ = tmp,ans=a;
		swap(str[n],ch);
		//cout<<a<<' '<<ch<<endl;
		//cout<<str<<endl<<endl;
	} while(next_permutation(str,str+10));
	if(a == 0) 
		for(int i=1;i<=n;i++)
			putchar('0');
	else {
		a = log(ans)/log(10);
		a++;
		for(int i=a;i<n;i++)
			putchar('0');
		cout<<ans;
	}
	cout<<endl;
	return 0;
}
```