import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class fox {
    static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String[] args) throws Exception {
        mainCyklus:
        while (true) {
            String line = input.readLine();
            if (line.equals("END"))
                return;
            char[] pole = line.toCharArray();
            if(pole[0] != '-'){
                int s = dsum(pole, 0, pole.length) + 1;
                boolean flag = false;
                for(int i = 0; i < pole.length; i++){
                    if(pole[i] != '9')
                        break;
                    if(i == pole.length - 1){
                        System.out.print("-1");
                        printPole(pole);
                        continue mainCyklus;
                    }
                }
                boolean eight = false;
                for(int i = pole.length - 1; i >= 1; i --){
                    if((('0' <= pole[i] && pole[i] <= '7') || (eight && pole[i] == '8'))
                            && pole[i - 1] != '0'){
                        flag = true;
                        pole[i-1]--;
                        int remainder = s - dsum(pole, 0, i);
                        while(remainder >= 9 || i < pole.length){
                            int cur = remainder >= 9 ? 9 : remainder;
                            pole[i] =(char) (cur + '0');
                            remainder -= cur;
                            i++;
                        }
                        printPole(pole);
                        continue mainCyklus;
                    }
                    if(pole[i] == '8')
                        eight = true;
                }
                if(!flag){
                     for(int i = pole.length - 1; i >= 0; i --){
                         if(pole[i] != '9'){
                             pole[i]++;
                            System.out.print('-');
                            printPole(pole);
                            continue mainCyklus;
                         }
                     }
                }
            }else{
                boolean flag = false;
                for(int i = pole.length - 1; i >= 1; i--){
                    if(pole[i] != '9'){
                        flag = true;
                        pole[i] ++;
                        System.out.print('-');
                        printPole(Arrays.copyOfRange(pole, 1, pole.length));
                        continue mainCyklus;
                    }
                }
                if(!flag){
                    System.out.print('-');
                    System.out.print('1');
                    printPole(Arrays.copyOfRange(pole, 1, pole.length));
                    continue mainCyklus;
                }
            }
        }
    }
    
    public static int dsum(char[] pole, int start, int end){
        int sum = 0;
        for(int i = start; i < end; i++){
            sum += pole[i] - '0';
        }
        return sum;
    }
 
    public static void printPole(char[] pole){
        System.out.println(pole);
    }
}