import java.util.Scanner;

/*
 * 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 gardlo1
 */
public class Owl {

    private static int cifernySucet(String cislo){
        int cifernySucet = 0;
        for (int i = 0; i < cislo.length(); i++) {
                cifernySucet += Integer.parseInt("" + cislo.charAt(i));
                
            }
        return cifernySucet;
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String cislo = "";
        while (!(cislo = sc.next()).equals("END")) {
            int zadaneCislo = Integer.parseInt(cislo);
            int cifernySucet = cifernySucet(cislo); 
            int noveCislo = zadaneCislo - 1;
            while(cifernySucet("" + noveCislo) != cifernySucet - 1){                
                noveCislo--;
            }
            System.out.println(noveCislo);            
            
        }

    }
}