#include <iostream>
#include <math.h>
using namespace std;

int sumOfCifer(int number)
{
	int sum = 0; 
	while (number > 0) {
		sum += number % 10;
		number /= 10;
	} 
	return sum;
}

int main()
{
	int N;

	while(cin >> N) {
		//cout << sumOfCifer(N) << endl;
		
		int pozadovanySoucet = sumOfCifer(N) - 1;

		int i = 0;
		while(true) {
			int substract = pow(10, i++);
			N -= substract;

			if(N < 0) {
				break;
			}

			if(sumOfCifer(N) == pozadovanySoucet)  {
				///if(orig - N) {
				
				//}
	
				cout << N << endl;
				break;
				
			}


			N += substract;

		}

	}

return 0;
}