/*
 * 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.
 */

import java.util.Scanner;

/**
 *
 * @author klempai3
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String cislo = sc.nextLine().trim();
            if(cislo.equals("END")){
                break;
            }
            int ret = 0;
            boolean change = false;
            int nasobok = 1;
            for(int i = cislo.length()-1; i >= 0; i--){
                int cifra = cislo.charAt(i)-'0';
                if(cifra>0 && !change){
                    cifra--;
                    change = true;
                }
                ret += cifra*nasobok;
                nasobok *= 10;
                
            }
            System.out.println(ret);
        }
    }
    
}