import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author cteam069
 */
public class Fox {

    public static void main(String[] args) throws IOException {

        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = r.readLine()) != null) {
            if (line.equals("END")) {
                return;
            }
            int n = Integer.parseInt(line);
            System.out.println(doIt(n));
        }

    }

    private static int doIt(int n) {
        if (n > 0) {
            return pos(n);
        } else {
            return neg(n);
        }
    }

    private static int neg(int n) {
        String num = "0" + String.valueOf(n).substring(1);
        int pow = 0;
        for (int i = num.length() - 1; i >= 0; i--) {
            if (num.charAt(i) != '9') {
                return n - (int) Math.pow(10, pow);
            }
            pow++;
        }
        throw new RuntimeException();
    }

    private static int pos(int n) {
        String num = String.valueOf(n);
        int pow = 0;
        for (int i = num.length() - 1; i >= 0; i--) {
            if (num.charAt(i) != '0' && canAdd(num, i)) {
                int result = Integer.parseInt(num);
                result -= (int) Math.pow(10, pow);
             //   System.out.println("resultA "+result);
                int added = 0;
                pow--;
                for (int r = i + 1;; r++) {
                    if (num.charAt(r) == '8') {
                        added++;
                        result += (int) Math.pow(10, pow);
                    } else if (num.charAt(r) != '9') {
                        int toAdd = 2 - added;
                        result += ((int) Math.pow(10, pow)) * toAdd;
                        return result;
                    }
                    pow--;

                }
            }
            pow++;
        }
        return neg(-n);
    }

    private static boolean canAdd(String num, int i) {

        int add = 0;
        for (int r = i + 1; r < num.length(); r++) {
            add += 9 - Integer.parseInt(num.charAt(r) + "");
            if (add >= 2) {
            //    System.out.println("can add " +num+" "+ i);
                return true;
            }
        }
        //System.out.println("cant add " +num+" "+ i);
        return false;
    }

}