#include <iostream>
#include <string>
using namespace std;
int main() {

	string str;
	while(cin >> str) {
		if(str == "END") break;
		if(str[0] == '-') {
			int i = str.length()-1;
			bool fixed = false;
			while(i>0) {
				if(str[i] == '9') {
					i--;
				} else {
					str[i]++;
					fixed = true;
					i = 0;
				}
			}
			if(fixed) {
				cout << str;
			} else {
				cout << "-1" << str.substr(1, str.length()-1) << endl;
			}
		} else {
			int i = str.length()-1;
			int add = 2;
			bool fixed = false;
			while(i>0) {
				if(add > 0) {
					if(str[i] == '9' || str[i-1] == '0') {
						i--;
					} else if(str[i] == '8') {
						str[i]++;
						add--;
						i--;
					} else  {
						str[i] += add;
						add = 0;
						i--;
					}
				} else {
					if(str[i] == '0') {
						i--;
					} else {
						fixed = true;
						str[i]--;
						i = 0;
					}
				}
			}
			if(fixed) {
				
				cout << str << endl;
			} else {
				if(add == 0) {
					if(str[0] == '1') {
						cout << str.substr(1, str.length()-1) << endl;
					} else {
						str[0]--;
						cout << str << endl;
					}
				} else {

					if(add == 1) {
						cout << "-" << str << endl;
					} else {
						if(str[0] == '9') {
							cout << "-1" << str << endl;
						} else {
							str[0]++;
							cout << "-" << str << endl;
						}
					}
			
				}
			}
		}
	}

	return 0;
}