#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for (int i=s;i<=t;i++)
#define pi acos(-1)
#define FOR(i,s,t) for (int i = s; i < t; i++)
typedef long long LL;
typedef long double LD;
typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef pair<PII, PII> PPP;
typedef pair<PII, int> PPI;
typedef pair<LL, PII> PLP;
typedef pair<double, PII> PDP;
#define repp(i,s,t) for (int i=s;i>=t;i--)
template<class T> T sqr(T x) {return x*x;}
#define debug(x) cerr<<#x"="<<(x)<<endl;
#define pb(x) push_back(x);
#define ori(x) x-'a'
#define y0 AERGAEWFAWERAw
#define y1 ASDFAEWRWERWERW
#define x0 gggsdfsfsfdf
#define x1 SAFREWRREWR
char str[4000001];
int main()
{
	scanf("%s",str);
	int n = strlen(str);
	if (str[0] == '0') puts("0");
	else
	{
		int FIRST = str[0] - '0';
		int last = 0;
		FOR(i,1,n) if (str[i] < str[i-1]) last = i;
		else if (str[i] > str[i-1]) break;
		rep(i,1,FIRST-1) putchar(i+'0');
		if (last == 0) putchar(FIRST+'0');
		rep(i,1,last)
		{
			int lefts = str[i] - '0';
			int rights = str[i-1] - '0';
			if (i == last) lefts++;
			rep(j,lefts,rights) putchar(j+'0');
			rep(j,0,lefts-1) putchar(j+'0');
			rep(j,rights+1,9) putchar(j+'0');
		}
		rep(i,last+1,n-1) rep(j,0,9) putchar(j+'0');
	}
}

