/*
 * 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.
 *//*
package owl;
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author cteam061
 */
public class Owl {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
        
        String line = null;
        while((line=br.readLine()).compareTo("END") != 0)    {
            
            String num = line;
            String cifCount = compute(num);
            
            
            System.out.println(Integer.parseInt(cifCount));
        }
    }
    
    public static String compute(String num)  {
        int cifCount = 0;
        StringBuilder sb = new StringBuilder(num);
        for(int i =num.length()-1; i >= 0; i--)    {
            if(num.charAt(i) != '0'){
                sb.setCharAt(i,set(num.charAt(i)));
                return sb.toString();
            }
        }
        
        return sb.toString();
    }
    
    public static char set(char c){
        return (char) (c-1);
    }
    
}